🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` #user nobody; #worker_processes 1; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; worker_rlimit_nofile 65535; events { # worker_connections 1024; use epoll; worker_connections 65535; accept_mutex off; multi_accept off; } 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; tcp_nopush on; tcp_nodelay on; #keepalive_timeout 0; keepalive_timeout 65; send_timeout 30s; types_hash_max_size 2048; client_header_buffer_size 4k; # 上传大小限制为 100M client_max_body_size 100m; proxy_connect_timeout 1200; proxy_send_timeout 1200; proxy_read_timeout 1200; proxy_buffer_size 64k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; #gzip on; gzip on; gzip_disable "msie6"; gzip_min_length 1024; gzip_vary on; gzip_comp_level 2; gzip_buffers 32 4k; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; map $http_upgrade $connection_upgrade { default upgrade; '' close; } # 负载均衡使用的默认的随机策略 upstream backendServer { server ip:port; server ip:port; keepalive 300; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } server { listen 80; server_name localhost; location / { root /home/xinye/front/pro-pl-web/html; index index.html index.htm; try_files $uri $uri/ /index.html; #解决页面刷新404问题 } location /api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 后台做了集群, 配置在上面 backendServer proxy_pass http://backendServer/; #升级http1.1到 websocket协议 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } } ```