Right now I have a server running on IP:Port. If I wanted to use DNS but redirect to the port, how would I do so? I've heard that it's possible, but how would I do so, even if it includes creating something such as a proxy?

For example, visiting:


would instead access


and the port could be anything I wanted it to be.

If no direct solution exist, how would I go along using a "VirtualHost"?

1 Answer 1


You could do this with Apache, or almost any other webserver, and in brief you'd configure your server to do two things:

  • Listen on :80 to accept the initial request.
  • When you so a request for example.com you'd then redirect to the alternative location. e.g.

However you will probably find visitors from large corporations, behind firewalls, will be unable to view your site. (Because their outgoing firewall might allow connections to the standard ports 80 + 443 but not others. So they'd redirect to a location they couldn't view.)

In short unless you have a fine reason for doing this then it is almost certainly a bad plan. (You don't can run an arbitrary number of sites on one webserver, each on port 80. If you need to run multiple SSL sites you will need extra IPs though, traditionally.)

Here's a brief example:


    ServerName example.com
    ServerAlias www.example.com
    Redirect 301 /

    ServerName example.net
    ServerAlias www.example.net
    Redirect 301 /

    ServerName example.org
    ServerAlias www.example.org
    Redirect 301 /
  • How would I go about doing this If I wished to redirect something that's not http or https? May 30, 2012 at 16:49
  • If you redirect to something that is not HTTP/HTTPs (albeit on a non-standard port) then the browser making the request is going to get confused .. so the question you're asking doesn't make a lot of sense!
    – user9565
    May 30, 2012 at 16:54
  • 2
    @hexacyanide - Two points: 1) http and https are protocols. They happen to typically run on 80/443 respectively, but there's nothing preventing you from running them anywhere you'd like. 2) Running these protocols on anything but their standard ports will be very problematic. Sure, it's fine to do that for development, but for production, you need to stick with 80 and 443.
    – EEAA
    May 30, 2012 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .