我真的是个新手,所以请原谅我的错误等等。
域:http://www.example.com
这两个玻璃鱼应用程序:
http://localhost:8080/app1
http://localhost:8080/app2
我想要的:
玻璃鱼app1餐厅:http://www.example.com
玻璃鱼app2餐厅:http://www.example.com/app2
现在我有:
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_pass http://localhost:8080/app1/;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Set-Cookie;
proxy_pass_header X-Forwarded-For;
proxy_pass_header Host; }
location /app2/ {
proxy_pass http://localhost:8080/app2/;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Set-Cookie;
proxy_pass_header X-Forwarded-For;
proxy_pass_header Host; }
}但是道路变得混乱了:当我做"http://example.com/app2“时,这就是"http://example.com/app1”,它出现了。
帮助?
发布于 2015-12-16 09:35:38
这可能是一个重定向问题,仅靠nginx可能解决,也可能无法解决。
应用程序通常向它们的控制器发出重定向,如果app2认为它在根中,它可能会发出重定向到/,该重定向将立即转发给app1。
您需要查看重定向标头,并确定是否可以将proxy_redirect放入您的位置容器中,以解决问题。
您还需要考虑app1和app2是否可以在子目录中工作。例如,它们使用相对路径或绝对路径访问CSS和JS文件。nginx无法更正这些引用。
https://stackoverflow.com/questions/34307875
复制相似问题