应用带根路径的情况
应用1请求为:http://localhost:8090/app1 应用2请求为:http://localhost:8091/app2
将根路径直接去掉,即 /
应用1请求为:http://localhost:8090/ 应用2请求为:http://localhost:8091/ 最后的/
不能少,否则会出现404
server {listen 8000;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}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;}# 为第一个应用配置路径location /app1 {proxy_pass http://localhost:8090/; # 转发到本机的8090端口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_set_header X-Forwarded-Proto $scheme;}# 为第二个应用配置路径location /app2 {proxy_pass http://localhost:8091/; # 转发到本机的8091端口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_set_header X-Forwarded-Proto $scheme;}}