Running Websites on Non-Standard Ports

These instructions will enable you to access your website externally via a port other than 80 (which might be blocked by your ISP).

Note that when using non-standard ports such as 8081 to host your website, to access your website you’ll need to specify the port number in the URL -

http://www.example.com:8081/

Edit VirtualHost

Select your website in WampDeveloper’s Websites Tab, click the HTTP VirtualHost button.

Replace this…

<VirtualHost *:80>

With this…

Listen 8081
NameVirtualHost *:8081
<VirtualHost *:8081>

Remove Redirect Rules

Then comment out (#) or remove the “Domain Alias to Primary Domain” redirect lines (if they are present), which are similar to these lines…

# Redirect all ServerAlias(es) to main domain
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^/*(.*)$ http://www.example.com/$1 [R=301,NC]

Save the VirtualHost file. Restart Apache.

Open and Route New Port

Sine you are probably doing this to open access to your server from outside, you’ll need to:

1. Open the new port in your Windows Firewall for incoming TCP requests.

2. And make sure your Router has the proper port-forward rules in place to forward WAN:port to LAN:port traffic, or the requests will never reach the proper LAN server.

Notes

1. If Apache won’t start, run from the command line (click Command Line button in System Tab):
httpd -n "Apache2" -t

Or if Apache service name is the default “Apache2.4″ or “Apache2.2″, then just:
httpd -t

2. From now on, you should not enable the ‘Forward To Primary Domain – All Aliases’ option for this website (in website’s Settings), as the above redirect lines might not work correctly for port specified URLs (*edit: now fixed in WampDeveloper v4.2.0.0 and above).

3. Also note that some parts of WampDeveloper might not been fully configured for running on non-standard ports; this could cause a few minor issues.

*Edit: WampDeveloper v4.2.0.0 and above now contains new Domain Aliases to Primary Domain Redirect rules that preserve port numbers, and it should not be necessary to comment-out or remove those rules/lines.

One thought on “Running Websites on Non-Standard Ports

  1. admin Post author

    If you check your domain name or IP address (plus port) in a Browser from outside, and get a message of:

    Chrome - This webpage is not available (Error code: ERR_CONNECTION_REFUSED)
    Internet Explorer - Internet Explorer cannot display the webpage

    This is not a timeout… The connection is being *actively* refused.

    This type of message is typically seen when a network level firewall is in place and is blocking traffic.

    Your network’s appliance/router/firewall needs to be set up to allow the incoming connection. Otherwise, those requests and TCP/IP packets are never going to reach the server.

    On the other hand, this can be your ISP blocking traffic at the network or modem level, and you’ll have to call them to get them to unblock port 80.

    Reply

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>