我正在尝试在nginx中配置反向代理。
http://apps.domain.example.com/abcadmin -> http://server1.exampl.com:8080/xyzadmin
因此,当我点击网址http://apps.domain.example.com/abcadmin
时,我应该可以在http://server1.exampl.com:8080/xyzadmin
中查看内容而无需重定向网址。
我尝试按如下方式配置服务器。但我没有得到预期的结果
upstream exe-al-server-up {
server exe-ser-ab.rds-dev:8080;
}
server {
server_name apps.domain.example.com;
proxy_pass_header Authorization;
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_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;
location /abcadmin/ {
rewrite ^/xyzadmin(.*) /$1 break;
proxy_pass http://imp-al-ra-up/xyzadmin/;
}
}
答案 0 :(得分:0)
您可以尝试更改重写规则。
upstream exe-al-server-up {
server exe-ser-ab.rds-dev:8080;
}
server {
server_name apps.domain.example.com;
proxy_pass_header Authorization;
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_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;
location /abcadmin/ {
rewrite ^/abcadmin(.*) /$1 break;
proxy_pass http://imp-al-ra-up/xyzadmin/;
}
}