Q: OSX Server Apache: How to Re-route http Request?
Hi all,
I have a Mac Mini running OSX Server El Capitan. It serves a couple of websites already. Normal server websites:
- site1.example.com
- site2.example.com
I have now installed an app that has its own web server built-in. That app would normally be accessible via http, on port 80. However, any http connections on port 80 are automatically trapped by OSX Server's built-in apache. Therefore, I have currently set the web app to run in a different port to apache. I have also setup a sub-domain, so that users can access that app directly, but they also have to type in the port as part of the URL - for instance, the new web app site is reachable at:
- myapp.example.com:7117
What I would like to do, is for the users to be able to simply access the app by using:
- myapp.example.com
I know that there is a way for us to get apache to automatically 'reroute' all requests for a sub-domain to an internal port, but I don't even know where to start. What files do we need to configure on OSX Server? How do we configure them?
Any guidance would be greatly appreciated.
Posted on Apr 23, 2016 10:53 PM
I had the same requirement and solved it the way you desire as detailed below.
- Set the additional app to run on a different port
- Create a site in Server.app using port 80 and the same host name as you intend to use for the additional app
- Define a redirect rule for this site in Server.app as follows
- Source = /, Destination = http://hostname.domain.com:1234/, Status = Permanent (301)
Obviously use the correct hostname, domain and port for your situation.
PS. The same approach as I detailed above can also be used to redirect port 80 to the matching https i.e. 443 site.
Posted on Apr 25, 2016 6:10 PM