简单说明:
listen:监听的IPserver_name:服务名此配置为一个ip代理多个地址如下配置代表访问http:\\192.168.0.150\abcd会访问第一个,访问 http:\\192.168.0.150\abc会访问第二个,但是访问第二个会影响第一个的cookie,所以添加proxy_cookie_path /abcd /abc;配置,防止nginx篡改cookieproxy_set_header这种配置为了防止nginx无法代理静态资源 server { listen 192.168.0.150; server_name aaaaa; location / { root html; index index.html index.htm; add_header 'Access-Control-Allow-Origin' *; } error_page 500 502 503 504 /50x.html; location /abcd/ { access_log logs/abcd.access.log; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:8088/abcd/; } location /abc/ { access_log logs/abc.access.log; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_cookie_path /abcd /abc; proxy_pass http://localhost:8088/abcd/add/page; } }资料:https://blog.csdn.net/SIMBA1949/article/details/86593595
