将 yoursite.com 域名下的所有路径反向代理到 localhost:8080:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| 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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| server {
server_name yoursite.com;
location / {
proxy_set_header Host $host;
proxy_pass http://localhost:8080/;
sub_filter "http://localhost:8080/" "https://yoursite.com/";
sub_filter_once off;
}
location /web02/ {
proxy_set_header Host $host;
proxy_pass http://localhost:18080/;
sub_filter "http://localhost:18080/" "https://yoursite.com/web02/";
sub_filter_once off;
}
# SSL settings
}
|