#user nobody; worker_processes auto; worker_rlimit_nofile 100000; error_log logs/error.log warn; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; client_max_body_size 10m; log_format main '$remote_addr $remote_user [$time_local] "$request" ' '"$http_host" $status $upstream_status ' '$body_bytes_sent "$http_referer" ' '"$http_cookie" "$http_x_forwarded_for" ' '"$upstream_addr" $request_time $upstream_response_time'; #配置按天生成日志文件 map $time_iso8601 $logdate { '~^(?\d{4}-\d{2}-\d{2})' $ymd; default 'date-not-found'; } access_log logs/access-$logdate.log main; error_log logs/error.log; server_tokens off; sendfile on; #tcp_nopush on; tcp_nodelay on; keepalive_timeout 60; client_header_timeout 10; client_body_timeout 10; reset_timedout_connection on; send_timeout 30; proxy_connect_timeout 60; proxy_read_timeout 60; proxy_send_timeout 60; gzip on; gzip_disable "msie6"; gzip_comp_level 6; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; gzip_min_length 1000; gzip_proxied any; gzip_vary on; add_header X-Frame-Options SAMEORIGIN; #设置访问的web应用列表 upstream app{ server 127.0.0.1:8080; } server { listen 80; server_name zhgh.nsi.edu.cn; #rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS。 location /{ proxy_pass http://app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header X-real-ip $remote_addr; proxy_cache_bypass $http_upgrade; } location /csrf.html{ root html; } #access_log logs/host.access.log main; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } #HTTPS server server { listen 443 ssl; server_name zhgh.nsi.edu.cn; ssl_certificate C:/env/ssl/_.nsi.edu.cn_bundle.crt; ssl_certificate_key C:/env/ssl/_.nsi.edu.cn.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location /{ proxy_pass http://app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header X-real-ip $remote_addr; proxy_cache_bypass $http_upgrade; } location /csrf.html{ root html; } #access_log logs/host.access.log main; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }