#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 1800; #gzip on; fastcgi_connect_timeout 300s; fastcgi_send_timeout 300s; fastcgi_read_timeout 300s; fastcgi_buffer_size 128k; fastcgi_buffers 8 128k;#8 128 fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; error_page 404 http://www.xxxx.com/admin/views/404.html; # max upload file 100M client_max_body_size 100M; client_body_buffer_size 128k; upstream backend { #ip_hash; #可配置多台服务器做负载均衡 server 1xxxxxx:8080 #max_fails=2 fail_timeout=30s ; #30秒内失败两次则踢出,30秒后恢复 server 1xxxxxx:8080 #max_fails=2 fail_timeout=30s ; } # 配置虚拟主机 server { listen 80; server_name www.xxx.com; location / { root /opt/web; #设置静态页面访问地址 index index.html; try_files $uri $uri/ @router; } location @router { rewrite ^.*$ /index.html last; } location ^~ /projectName/ { #匹配包含projectName的请求 proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_connect_timeout 50s; proxy_read_timeout 50s; proxy_send_timeout 50s; #上传大文件防止超时设置 } } }