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'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
</Directory>`

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/domainx.be
ServerName domainx.be
ErrorLog logs/domainx-error_log
CustomLog logs/domainx-access_log common
</VirtualHost>

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
add comment

2 Answers 2

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 == "domainx.be") {
           include "/etc/varnish/domainx.be.vcl";
       }
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
add comment

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 127.0.0.1 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
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.