第一次发主题,我在配置 nginx 的时候遇到个问题,想请教一下大家,希望大家不吝赐教。
location /sign_in {
proxy_pass http://127.0.0.1:8080/one/sign_in;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /sign_out {
proxy_pass http://127.0.0.1:8080/one/sign_out;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /api/v1/management{
proxy_pass http://127.0.0.1:8080/two/api/v1/management;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
像上边这样的配置,能不能配置成底下这样?
location ~ /(one|two) {
proxy_pass http://127.0.0.1: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;
}
如果不行那么应该如何精简? rewrite 吗?
谢谢大家。