我们有一个URL www.abc.com,应该指向在wildfly-8.2.0.Final上运行的http:// IP:8080 / app1 / index.html 。 我们有另一个URL www.def.com,我们想要在同一个野蛮装置上指向http:// IP:8080 / app2 / index.html 。
如果我们使用:
server { listen IP:80; server_name www.abc.com; location / { 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_set_header X-Forwarded-Proto $scheme; proxy_pass http://IP:8080/; } }
这工作,并允许我们反向代理www.abc.com到http:// IP:8080 /这意味着我们得到默认的蜻蜓页面。 这不会帮助我们,因为我们有多个url需要反向代理到不同的野蛮应用程序。
这没有奏效。
server { listen IP:80; server_name www.abc.com; location / { 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_set_header X-Forwarded-Proto $scheme; proxy_pass http://IP:8080/app1/; } }
这没有奏效。
server { listen IP:80; server_name www.abc.com; location / { 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_set_header X-Forwarded-Proto $scheme; proxy_pass http://IP:8080/; root /var/www/www.abc.com/public_html; index index.html; } }
index.html如下所示:
<html> <head> <meta http-equiv="Refresh" content="0;url=/app1/index.html"> <title>Index Redirect</title> </head> </body> </html>
任何build议感激。
我有非常喜欢它运行的东西,虽然我的后端是JBoss,而不是蜻蜓。 在相关部分,跳过我的SSLconfiguration:
www1.example.com:
server { listen IP:80; server_name www1.example.com; location / { location /app1 { proxy_pass http://IP:8080/app1$request_uri; proxy_redirect http://IP:8080 http://www1.example.com; # proxy_set_header directives as needed } } location = / { return 301 http://www1.example.com/app1 } }
www2.example.com
# Like www1, but server_name www2.example.com and proxy paths set for app2.
我不知道是否可以在隐藏外部应用程序path的情况下工作,但我怀疑它可以简单地通过将所有的代理指令移动到location /并省略location = / {}