We have a URL www.abc.com that should point to http://IP:8080/app1/index.html running on wildfly-8.2.0.Final. We have another URL www.def.com that we want to point to http://IP:8080/app2/index.html on the same wildfly installation.
If we use:
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/;
}
}
This works and allow us to reverse proxy www.abc.com to http://IP:8080/ which means we get the default Wildfly page. This will not help us as we have multiple URLs that need to be reverse proxied to different apps on wildfly.
This did not work.
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/;
}
}
This did not work.
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;
}
}
The index.html looks like:
<html>
<head>
<meta http-equiv="Refresh" content="0;url=/app1/index.html">
<title>Index Redirect</title>
</head>
</body>
</html>
Any suggestions appreciated.
Best Answer
I have something very much like it running, though my backend is JBoss, not Wildfly. In relevant part, skipping my SSL configuration:
www1.example.com:
www2.example.com
I have no idea whether this can be made to work while hiding the application path from the outside world, but I suspect it can be simply by moving all the proxy directives to
location /
and omittinglocation = / {}