Ubuntu – How to disable varnish on apache2 with ubuntu


I installed and setted up varnish using this guide

Basically, I changed the port to 8080,

I want to disable varnish, so I thought I will change back to port 80 and thats it, varnish it's listening to 8080,

The thing is that I edited:

sudo nano /etc/apache2/ports.conf:

#Listen 80
NameVirtualHost # it was 8080
Listen # it was 8080

<IfModule ssl_module>
        Listen 443

<IfModule mod_gnutls.c>
        Listen 443

And then, sudo nano /etc/apache2/sites-available000-default.conf:

<VirtualHost *:80> # it was 8080

The problem was when restarting apache2, I got this error

 * Stopping HTTP accelerator varnishd                                                [ OK ] 
 * Starting HTTP accelerator varnishd                                                [ OK ] 
root@funcook:/etc/apache2/sites-available# sudo service apache2 restart
 * Restarting web server apache2                                                            AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/ports.conf:6
(98)Address already in use: AH00072: make_sock: could not bind to address
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

So I changed back to 8080 and restarting apache fired no errors,

Any idea what am I missing here?


Best Answer

Seems that varnish is listening to port 80.

You can check it by issuing as root:

netstat -natpe |grep 80

to see if the port is in use.

If it is, you have to stop varnish (if it is varnish using the port 80 -most probable-) or change it's port and restart.

In other words, in the guide where it says:

sudo nano /etc/default/varnish

Uncomment all of the lines under “DAEMON_OPTS”—under Alternative 2, and make the configuration match the following code:

DAEMON_OPTS="-a :80 \

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

the -a option says in which port varnish is listening... and is 80, is not possible both services to open a socket in the same port.

We found after discussing the problem that ip should be rolled back in ports file too, as the guide asked to change it to listen on instead of any public interface. The guide says:

sudo nano /etc/apache2/ports.conf

Change the port number for both the NameVirtualHost and the Listen line to port 8080, and the virtual host should only be accessible from the localhost. The configuration should look like this:

NameVirtualHost Listen

Should be rolled back to Listen *:80 or Listen :80 for being publicly accessible again