我喜欢做的是代理来自的http://example.com/proxy/foo
请求http://localhost:8060/foo
此配置代理http://example.com/proxy/foo
至http://localhost:8060/proxy/foo
server {
server_name example.com;
location /proxy/ {
proxy_pass http://localhost:8060;
}
location / {
proxy_pass http://localhost:8040;
}
}
答案1
server {
server_name example.com;
location ^~ /proxy/ {
rewrite ^/proxy(/.*)$ $1 break;
proxy_pass http://localhost:8060;
}
location / {
proxy_pass http://localhost:8040;
}
}