How To: Port Redirect Web Traffic On Lion Server

Standard

UPDATE: With the release of 10.7.3, you can now do this via “Server.app”, so i’d advise against the below method. If you have used the below & upgraded to 10.7.3 & have an error in “Server.app” when managing the web service, click here.

Port redirection is (simply put), where an end user enters: http://mygreatwebsite.com & they are redirected to http://mygreatwebsite.com:(someport).

On Snow Leopard server you could easily set port redirects from within the Server Admin.app, but in Lion server this has all been changed.

The basics of how to enable virtual hosts on Lion server, is covered in this post. As well as links to the more advanced options.

Once Virtual Hosts have been enabled, editing /private/etc/apache2/extra/httpd-vhosts.conf enable the redirects. 

For this example we’ll take the Jamf Software Server (read: JSS). By default, it hosts it’s HTTP service on port 9006. The URL for the JSS in this example is http://jss.mycompany.com:9006.

What we wish to achieve is that when users enter http://jss.mycompany.com into a browser, they are redirected to http://jss.mycompany.com:9006.

  1. In Terminal type:
  2. Press Enter
  3. Under the section “Use name-based virtual hosting.”
  4. Enter: “NameVirtualHost jss.mycompany.com:*”
  5. In the VirtualHost section enter the below:
  6. Press “CTRL + X”
  7. Press “Y”
  8. Press Enter
  9. Restart the Web service (flick the switch!)

In step 3 the server is listening for connections via the dns entry jss.mycompany.com.

In step 4 the server is redirecting all port 80 (read; HTTP) connections via the dns entry jss.mycompany.com to http://jss.mycompany.com:9006.

One thought on “How To: Port Redirect Web Traffic On Lion Server

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.