Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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. –  Evan Anderson Oct 29 '09 at 6:33
add comment

3 Answers

up vote 2 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.