Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a domain name which points to a static IP address. I have configured in my modem so that all request to port 80 of this static IP will come to my local computer (web server).

Now I want to have 2 sub-domain point to 2 another local IP: ---> (host another web server) ---> (host redmine server)

Is this possible? If yes, please show me how?

I use Ubuntu Server 12.

share|improve this question

Answer thanks to JoshP in Server Fault:

I just recently did this. See my question. It was kind of a long back and forth, but I did get it set up in the end.

  • Set up DNS. The A record will point to your public IP. So, points to Add CNAME records for the subdomains. So, points to @, and points to @, etc. Although the subdomains are all pointing to the same address, the browser will confer to the webserver which subdomain you are trying to reach.

  • Set up Apache. You'll want to set up Virtual Hosts for each subdomain (and maybe for primary domain as well). You can define the Virtual Hosts in different places... mine is defined in /etc/apache2/sites-available, and includes the <Location> directive, which is where you'll set up your reverse proxy.

This answer was given to OP in ServerFault.

share|improve this answer
It's not a great answer though, without an example of e.g. the Virtual Hosts config.. – geotheory Jun 3 at 13:58
@geotheory it doesn't really matter. It explains what is to be done and there are excellent guides elsewhere. As its now, if Apache (or whatever your webserver is) changes something this answer will be still canonical as it doesn't depends on the specific implementations of any version of the webserver. – Braiam Jun 3 at 15:29

The easiest way would be to modify your hosts file, which is in /etc/.

It would look like this:

# This is an example of the hosts file  localhost loopback webserver sub1 sub2
share|improve this answer
Hi badgerhill, I have changed my host file but it not works. When I ping, it show my static IP address, but ping the error show: "Ping request could not find host Please check the name and try again". Please help! – thang nhoc Aug 8 '12 at 3:40

Clients on your lan will need to have thier hosts file updated too unless you install and configure a DNS server too and have your clients use it. dnsmasq is easy and has lots of helpful comments in the config file. BIND is another but its config file uses a bizarre nonsensical syntax that nobody really understands. Unbound is another one with a strong emphasis on security.

share|improve this answer

If I understand correctly, you only have 1 public IP address (on inherently only 1 tcp port 80 on that), but you want to run 3 webservers of which only 1 is direcly public accessible (through a port forward).

You have 2 things to configure:

  1. DNS level: make sure www. sub1. sub2. all point to the same address as This can be done in the configuration panel of your DNS registrar (look for a "Wildcard" option if available). This should allow you to ping and all other subdomains.
  2. As all requests arrive on the server, you'll need to configure this webserver to forward requests for the subdomains to other (internal) servers.

The other servers can be accessed if you use the main webserver (.100) as a reverse proxy for the subdomains sub1. and sub2.

I think this might be a good sample: sample httpd.conf with explanation

Note: in the ProxyPass and ProxyReverse lines you'll have to use an internal hostname or IP address, not the because that will have you end up with a loop!

If it doesn't work with that website, here are the google search terms: vhost reverse proxy

Good luck!

share|improve this answer
Thanks for your answer. Sorry but I don't have enough reputation to vote you up. Thanks again bro – thang nhoc Aug 14 '12 at 2:34

Your Answer


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.