0

I am running an Apache web application server internally, at App.domain.com. It is exposed externally by using port forwarding at the firewall/gateway as app.domain.com:10080.

Access generally works both inside (http://app.domain.com) and outside (http://app.domain.com:10080), except that during development and configuration, (being done from the outside), somehow the application stored the port (10080) in its configurations and this occasionally pops up in some of the URLs served. This then shows up as "http://app.domain.com:10080/some/text/..."

This is not an issue from the outside where the development is occurring and it resolves correctly, but it generates an error when being accessed from the inside, as the server is not running on port 10080, but on port 80.

I am now trying to fix this and wondering which is the preferred method for addressing this. Should I simply proxy requests on 10080 to port 80 using a separate VirtualHost directive:

<VirtualHost *:10080>
        ProxyRequests Off
        ProxyPreserveHost On
<Proxy *>
        AddDefaultCharset Off
        Order allow,deny
        Allow from all
</Proxy>
        ProxyPass / http://app.domain.com/
        ProxyPassReverse / http://app.domain.com/
</VirtualHost>

or should I use a Redirect:

<VirtualHost *:10080>
##{and any one of:}
              Redirect permanent / http://app.domain.com/
## OR ##      Redirect / http://%{HTTP_HOST}$1
## OR ##      Redirect / http://app.domain.com/
</VirtualHost>

Or does this call for a mod_rewrite?

I have tried a couple of options, but I still seem to not get it to work just right as some pages (proxied/redirected) do not seem to render just right and maybe my entries are not done quite right.

I would eventually need to do the same thing also for https, but I'm first trying to get it to work on http, which I could then replicate.

Server version: Apache/2.4.18 (Ubuntu) / Server built:   2017-09-18T15:09:02

Thanks for any pointers.

1 Answers1

0

Redirect: Return a redirect response to the client.

Rewrite: Internally change what the URL points to without the client's knowledge. It can optionally return a redirect response to the client but this is much more complex and error prone.

Proxy: Forwarding requests somewhere else and return the responses to the client.

If fixing this in the application is not an option, a Redirect will be the simplest, easiest and fastest solution.

In your case, you'll want to use:

Redirect permanent "/" "http://app.domain.com:80/"
Joshua Griffiths
  • 2,202
  • 15
  • 19