I would like to make my local website (running on a virtual CentOs machine) accessible for my mate who is also working on the website. I have created a new line in my router config to forward all requests on port 8080 to my centos machine. I've setup apache to listen on port 8080 as my ISP blocks port 80. I've setup my VHosts to use port 8080. When my mate now tries to go to http://my_external_ip:8080, he can see my apache welcome page. I've asked him to enter this in his hosts file. my_external_ip www.my_local_domain_name.com

When he types that url into his browser, the site doesn't load. What could this be?

  • You should not use .com in this case but rather .local – Raffael Luthiger Dec 28 '11 at 14:00
  • okay, thx for the tip. But still looking for the solution – mattyh88 Dec 28 '11 at 16:48
  • You'll probably have to create a DNS entry to point your domain to your external IP check my answer below. – Anagio Mar 1 '12 at 9:54

In your apache virtual host configuration (where you specified that is should listen on port 8080), be sure to add www.mydomain.local (or whatever you use) as a ServerAlias.

Simply just add a line below the initial <virtualHost *:8080> tag, saying:

ServerAlias www.mydomain.local

Update: Your mate also needs to be able to resolve www.mydomain.local to the actual IP address

He'll need to add a line to his /etc/hosts file (if he is also running CentOS/Debian/Linux), if he's running windows, add it to C:\Windows\system32\drivers\etc\hosts

If your external IP is, his entry should look like this: www.mydomain.local

  • Done that. My virtual host setup works for me. It just doesn't for my mate. – mattyh88 Dec 29 '11 at 8:29
  • Make sure he can resolve the hostname, check out my update – Mathias R. Jessen Dec 29 '11 at 17:04
  • Yes we have done all that :) – mattyh88 Dec 29 '11 at 18:03

I think the problem is in your Apache configuration, and perhaps with the IP addresses you are using with Apache.

Check the IP address that CentOs is really using. You probably have a public IP address that your ISP assigns to you, but your CentOs VM is certainly running on a local IP address like (for example). This is the IP address Apache must listen to, not your public IP.

You can run ifconfig in console to see what IP the VM is using. Make sure you have set up CentOs to use a static IP (not DHCP) or you might be using a different local IP every time you restart your machine.

Open /etc/httpd/conf/httpd.conf. If you want Apache to reposnd to port 8080, make sure you have a line like this before all the Virtual Host stuff (assuming as the static IP of CentOs):


Then set Apache to run virtual hosts on this IP:

    ServerName www.mydomain.local
    ServerAlias mydomain.local #or whatever

You may want to also put this in your own /etc/hosts file as well: www.mydomain.local

Then you can access the same domain name locally.

  • I'll try to add the IP in front of the port as I just have "Listen 8080" at the moment. I have done all of the other things you've written down here ... but still not working. I'm starting to think it has something to do with firewall on my host OS? I've tried shutting it off, but my mate still couldn't access the site. Perhaps something with the network settings in virtualbox ... – mattyh88 Jan 3 '12 at 9:25

I have an apache2 server configured on a local server with a private IP. My linksys routes http, mysql, ssh, and ftp to that private IP. I think it's under Applications or Forwarding in the linksys dashboard. I then use Amazon route 53 with an A record to my External IP. So anyone connecting to www.example.com is routed to my IP, reaches my linksys and that routes the connections to my local apache2 server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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