我想将我的Nginx版本1.10.2配置为CentOS 7操作系统中托管的反向代理。我在同一个WildFly 10服务器上运行了几个应用程序。这些应用程序可以在http://213.xxx.xxx.xxx/app1和http://213.xxx.xxx.xxx/app2上找到。我为app2 http://app2.example.com创建了一个子域。我的nginx.conf文件包含这些服务器:
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_pass http://213.xxx.xxx.xxx/app1;
}
}
server {
listen 80;
server_name app2.example.com www.app2.example.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://213.xxx.xxx.xxx/app2;
}
}在我的网页浏览器中,我可以通过URL example.com访问app1。但我联系不上app2当我向app2.example.com发送请求时,它会将我重定向到app2.example.com/app2。有人能告诉我我的配置出了什么问题吗?
发布于 2017-08-31 15:09:58
似乎你是应用程序做了重定向,这就是为什么app1工作而app2不工作的原因。现在,您可以尝试的事情很少
server {
listen 80;
server_name app2.example.com www.app2.example.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://213.xxx.xxx.xxx/app2;
proxy_redirect http://213.xxx.xxx.xxx/app2/ http://$host/;
}
}https://stackoverflow.com/questions/45965517
复制相似问题