자유게시판
  • 댓글
  • 글쓰기

nginx 설정

본문

nginx 설정

명령어: vi /etc/nginx/nginx.conf

 

# For more information on configuration, see:

#   * Official English Documentation: http://nginx.org/en/docs/

#   * Official Russian Documentation: http://nginx.org/ru/docs/


user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;


# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.

include /usr/share/nginx/modules/*.conf;


events {

    worker_connections 1024;

}


http {

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';


    access_log  /var/log/nginx/access.log  main;


    sendfile            on;

    tcp_nopush          on;

    tcp_nodelay         on;

    keepalive_timeout   65;

    types_hash_max_size 4096;


    client_max_body_size 100M;


    include             /etc/nginx/mime.types;

    default_type        application/octet-stream;


    # Load modular configuration files from the /etc/nginx/conf.d directory.

    # See http://nginx.org/en/docs/ngx_core_module.html#include

    # for more information.

    include /etc/nginx/conf.d/*.conf;


    server {

        server_name  banbu.monster www.banbu.monster;

root /usr/share/nginx/html; # 기본 root 경로를 html로 변경



# phpMyAdmin 경로 처리

    location ^~ /phpMyAdmin/ {

        alias /usr/share/nginx/html/phpMyAdmin/; # 끝에 슬래시 추가

        try_files $uri $uri/ =404;


        # PHP 파일 처리를 위한 location 블록이 필요할 수 있음

        location ~ \.php$ {

            include fastcgi_params;

            fastcgi_pass unix:/run/php-fpm/www.sock; # PHP-FPM 설정에 따라 다를 수 있음

            fastcgi_index index.php;

            fastcgi_param SCRIPT_FILENAME $request_filename;

        }

    }


    # html에 대한 기본 처리 구성

    location / {

        try_files $uri $uri/ /index.php?$args;

    }


    # Load configuration files for the default server block.

    include /etc/nginx/default.d/*.conf;


    error_page 404 /404.html;

    location = /404.html {

    }


    error_page 500 502 503 504 /50x.html;

    location = /50x.html {

    }

  # 그누보드5 nginx rules BEGIN

    if (!-e $request_filename) {

    rewrite ^/shop/([0-9]+)$ /shop/item.php?it_id=$1 break;


        rewrite ^/content/([0-9a-zA-Z_]+)$ /bbs/content.php?co_id=$1&rewrite=1 break;

        rewrite ^/content/([^/]+)/$ /bbs/content.php?co_seo_title=$1&rewrite=1 break;

        rewrite ^/rss/([0-9a-zA-Z_]+)$ /bbs/rss.php?bo_table=$1 break;

        rewrite ^/([0-9a-zA-Z_]+)$ /bbs/board.php?bo_table=$1&rewrite=1 break;

        rewrite ^/([0-9a-zA-Z_]+)/write$ /bbs/write.php?bo_table=$1&rewrite=1 break;

        rewrite ^/([0-9a-zA-Z_]+)/([^/]+)/$ /bbs/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1 break;

        rewrite ^/([0-9a-zA-Z_]+)/([0-9]+)$ /bbs/board.php?bo_table=$1&wr_id=$2&rewrite=1 break;

    }

    # 그누보드5 nginx rules END

    

    listen [::]:443 ssl ipv6only=on; # managed by Certbot

    listen 443 ssl; # managed by Certbot

    ssl_certificate /etc/letsencrypt/live/banbu.monster/fullchain.pem; # managed by Certbot

    ssl_certificate_key /etc/letsencrypt/live/banbu.monster/privkey.pem; # managed by Certbot

    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

    server {

    if ($host = banbu.monster) {

        return 301 https://$host$request_uri;

    } # managed by Certbot



        listen       80;

        listen       [::]:80;

        server_name  banbu.monster www.banbu.monster;

    return 404; # managed by Certbot



}}


추천0 비추천 0

댓글목록 0

등록된 댓글이 없습니다.

공지글


최근글


새댓글


  • 댓글이 없습니다.