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.

hillel
  • 11
  • 1
  • 3

1 Answers1

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

  • hi I tried doing this but its not working.I did this location / { proxy_pass http://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 – kirti Nov 09 '15 at 13:45