1

I saw other questions about this that were similar, but not exact.

So, my issue is, I have a home server that hosts my website and uses my outside ip. Well, rather my domain name directs to that ip. I have a second computer that I would like to run a webserver on as well. The only way I could think of to do this was to use a different port and still access my domain. Do, www.mydomain.com would take me to my main site, but www.mydomain.com:8080 would take my to my second computer that his hosting a site.

Does this make sense? It is this possible since these are different computers and I really only have 1 ip.

I think I could make a subdomain like sub.mydomain.com but not sure if this would help.

Thanks.

1
  • 3
    If you really want to get fancy you could use a reverse-proxy to answer connections coming from the Internet and host an arbitrary number of web sites internally on an arbitrary number of computers. Oct 29, 2009 at 6:33

3 Answers 3

2

yes, you can run a separate website on a different port. But as far as having a subdoamin, it wont really matter because a domain can only point to an ip address, not an ip address + port. By default web sites use port 80:

http://domain.com is the same as http://domain.com:80

so if you have a subdomain and you run a website on a different port, you're gona have to specifiy the port with it, i.e. http://sub.domain.com:8080

1

You could also specify virtual hosts in your port 80 server so that a certain domain (sub.mydomain.com) would redirect to sub.mydomain.com:8080.

Put this at the end of your httpd.conf file (assuming Apache with mod_rewrite):

NameVirtualHost *:80

<VirtualHost *>
  ServerName mydomain.com
  DocumentRoot "C:/Web/Docs/"
</VirtualHost>

<VirtualHost *>
  ServerName sub.mydomain.com
  DocumentRoot "C:/Web/Docs/FileWithPHPRedirect/JustInCase"
  RewriteEngine On
  RewriteCond %{SERVER_PORT} !8080$
  RewriteRule ^(.*) https://sub.mydomain.com:8080$1 [R=301,L] 
</VirtualHost>

Have your firewall forward port 8080 to the second server. The paths here are Windows paths, just change them if need be.

0

There are a couple options here depending on exactly what you want to do. Both machines can't answer on the same IP and same port, so the easiest solution is to run it on another port.

I would instead use the primary machine as the DNS entry and then gate traffic from there. So you could set up your webserver to proxy or redirect the other domain, or even subfolder to the other machine.

So www.domain.com would go to machine1. www.domain.com/otherfolder would still go to machine1, but would then be redirected or proxied to machine2. Redirecting is easy to setup, but the URL would still have the alternate port in it. Proxy is the most transparent, because everything is still directly talking to machine1. It may respond a little slower though, because all the communication is going through both webservers before it gets to the end client.

You must log in to answer this question.

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