将yoursite.com
域名下的所有路径均反向代理到localhost:8080
:
server {
root /var/www/html;
server_name yoursite.com;
location / {
proxy_pass http://localhost:8080;
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;
proxy_redirect off;
}
#ssl settings
}
将根路径代理到localhost:8080
而将/web02
代理到localhost:18080
:
server {
server_name yoursite.com;
location / {
proxy_set_header Host $host;
proxy_pass http://localhost:8080/;
sub_filter "http://yoursite.com/" "http://localhost:8080/";
sub_filter_once off;
}
location /web02/ {
proxy_set_header Host $host;
proxy_pass http://localhost:18080/;
sub_filter "http://yoursite.com/" "http://localhost:18080/";
sub_filter_once off;
}
#ssl confs
}