1

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.

1
  • What does "doesn't work" actually mean? What do your nginx debug logs say? Commented Nov 9, 2015 at 0:37

1 Answer 1

1

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:

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. 

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 omitting location = / {}

1
  • hi I tried doing this but its not working.I did this location / { proxy_pass IP:8080; location /app1 { root /var/www/www.abc.com/public_html; index index.html; } } I want it to redirect to Ip:8080/app1/index.html index.html is in root directory but its not working.. can you help me out in this Commented Nov 9, 2015 at 13:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.