单端-代理配置代码
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #服务:可以多个服务反向代理server { #前端代理的端口listen 80; server_name localhost; charsetutf-8; #前端资源配置location / { #使用root 下面为前端页面路径root /www/wwwroot/police/dist; #指向不能错/index.html如果配置错误会报:500 Internal Server Errortry_files$uri $uri/ /index.html; indexindex.html index.htm; } #后端反向代理配置location /prod-api/ { proxy_set_headerHost $http_host; proxy_set_headerX-Real-IP $remote_addr; proxy_set_headerREMOTE-HOST $remote_addr; proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for; #后端代码接口配置proxy_passhttp://localhost:8080/; } error_page 500 502503 504 /50x.html; location = /50x.html { root html; } } }