nginx简易配置

nginx.conf 包含子目录配置

# Load dynamic modules. See /usr/share/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 2048;

    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; # 多个域名配置
}

 

/etc/nginx/conf.d/ 示例 guest.conf
server {

    listen   443 ssl http2;
    server_name ****.com;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DHE+AES128:!ADH:!AECDH:!MD5;
    ssl_dhparam /etc/nginx/cert/dhparam.pem;
    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 30m;
    ssl_certificate  /etc/nginx/***.pem;
    ssl_certificate_key /etc/nginx/***.key;

    proxy_read_timeout 3600s;
    proxy_send_timeout 3600s;
    client_max_body_size 4G;

    access_log /var/log/nginx/***.com.access.log;
    error_log /var/log/nginx/***.com.error.log;

    root /data/wireless_guest3/wireless_guest3/;
    index index.html index.htm;

    location ^~ / {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }


    location ^~ /static/ {
        root /data/wireless_guest3/wireless_guest3/;
    }


    # Error pages
    error_page 500 /500.html;
    error_page 403 /404.html;
    error_page 404 /404.html;

    # Fallback Directory
    location @error {
       root /var/www/error;
    }
}

 



 

posted @ 2021-01-07 11:56  士为知己  阅读(107)  评论(0)    收藏  举报