server { #修改要监听的端口 listen 8080; #修改要绑定的域名或IP地址 server_name localhost; # charset koi8-r; access_log logs/logs.access.log main; # 后端接口 生产环境 location /prod-api/ { proxy_pass http://localhost:8888/; # 后端的Web服务器可以通过X-Forwarded-For获取用户真实IP proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 如果请求被负载均衡的服务器返回类似500这样的,将继续请求下一台应用服务器,默认 对post,lock,patch的请求不进行重试,如果要设置在后面添加 non_idemponent # proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; } # vue项目配置 location / { #将xxxxx路径改成你的发布路径 root html/zradmin_vue; index index.html; try_files $uri $uri/ /index.html; } 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; } }