I have a 13.04 Ubuntu server with two associated ip addresses. Let's say for example the IPs are 123.456.789.111 and 123.456.789.222 and the server has two domains let's say example1.com and example2.com.

I currently have example2.com being served by Apache and I have example1.com being served by Varnish > Nginx. Except example1.com is actually being served by apache is though all the settings show it should be being served by nginx.

In the DNS example1.com is pointed to 123.456.789.111 and example2.com is pointed to 123.456.789.222.



I have it set to:

NameVirtualHost 123.456.789.222:80
Listen 80

So any domains pointed to that domain should get served by Apache which is what happens.



I have it set to:

DAEMON_OPTS="-a 123.456.789.111:80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

So any sites pointed to that domain should get picked up by Varnish.

Then in:


I have it set to:

backend default {
    .host = "";
    .port = "8080";

Which forwards everything from varnish to nginx since in:

root /var/www/example1.com/public/

I have:

server {

To note I also simlinked that domain to sites-enabled/example1.com as well.

So example1.com should be loaded by Varnish and then served by Nginx but in reality it's loading content from:


Also if I do www.isvarnishworking.com with example1.com it says its not loading through varnish. (and yes I'm using the actual domain name not example1.com which I'm using for the purpose of this post).

Also I did restart for Varnish Nginx and Apache service and all of them restart without any issues.

Also I disabled the default site in nginx:

sudo rm -v /etc/nginx/sites-enabled/default

Also in:


example1.com does not exist (as it shouldn't since I don't want it loaded by Apache).

I don't know what else to check. Does anyone have an ideas or commands to run that may help me see what example1.com isn't being loaded by apache and being passed to nginx?

** UPDATE **

If I stop nginx, apache2 and varnish and turn varnish and nginx on first, then example1.com does load using varnish and nginx properly. However then if I run:

sudo service varnish start

It says:

(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address

I'm not sure why though because yes both apache and varnish are listening on port 80 but they are listening for port 80 on different IP addresses.

| improve this question | | | | |

It appears that in /etc/apache2/ports.conf you have the Listen 80 rather than, say Listen 123.456.789.222:80. That way the port is would be bound to specific IP address.

| improve this answer | | | | |
  • Ah that did it. I assumed that having the IP next to NameVirtualHost handled that. Didn't realize it also had to be added to Listen. Thanks so much! – cchiera Aug 25 '13 at 15:47

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.