0

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.

In

/etc/apache2/ports.conf

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.

In

/etc/default/varnish

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:

/etc/varnish/default.vcl

I have it set to:

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

Which forwards everything from varnish to nginx since in:

/etc/nginx/sites-available/example1.com
root /var/www/example1.com/public/

I have:

server {
        listen 127.0.0.1:8080;

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:

/var/www/

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:

/etc/apache2/sites-enabled

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 0.0.0.0:80

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.

1 Answer 1

2

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.

1
  • 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! Aug 25, 2013 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .