Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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've been reading multiple questions about this topic but I can't seem to get it working...

I have a server running CentOS with HTTPD running 1 website under the default httpd root:

Listen 8080
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

I'm also running Varnish: Varnish is listening on port 80 and forwarding requests to httpd, which is listening on port 8080

Now I want to run a second domain on this server, so I added a .conf file under /etc/httpd/conf/ with the following:

<VirtualHost *:8080>
ServerAdmin root@localhost
DocumentRoot /var/www/vhosts/
ErrorLog logs/domainx-error_log
CustomLog logs/domainx-access_log common

When I apply the above, all traffic (including that of the root domain) is routed to domainx. When I change the port of the vhost to 80, domainx gets forwarded to the root host.

This is the first time I'm doing this without something like Plesk of Webmin installed so I'm not sure where to go from here....

share|improve this question
up vote 0 down vote accepted
  • Create a virtual host for your website which is pointing to the document root. Remember adding NameVirtualHost *:8080.

  • Put the backend configuration in one file and then include it based on the hostname requested:

       if (req.http.Host == "") {
           include "/etc/varnish/";
share|improve this answer
I've added a vhost for my root domain as mentioned above and now it's working, thx! – Jannemans Oct 7 '11 at 4:54

Make vhosts entries for each virtual host, even the "real" site, and don't forget to include ServerName. That should fix your Apache setup.

Personally I also always run apache on port 80 and Varnish on the public IP port 80. That way you don't have problems with $_SERVER vars thinking Varnish runs on port 8080.

share|improve this answer

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.