Reputation: 133
Have installed Varnish cache successfuly but now when I try to use: systemctl status varnish - it's giving me an error Could not get socket :80: Address already in use.
I have checked the sockets by using netstat -plntu and it seems like that this is the problem:
206.189.99.109:80 0.0.0.0:* LISTEN 31889/nginx: master
10.18.0.8:8080 0.0.0.0:* LISTEN 31889/nginx: master
206.189.99.109:8080 0.0.0.0:* LISTEN 31889/nginx: master
one of the Nginx: master is running under port 80 I have tried to change the port in nginx config files but nothing.
How or where can I change this port to 80?
Upvotes: 0
Views: 1858
Reputation: 4808
In nginx
, you have to change to port in the config file that holds your vhost config.
Usualy listen 80
is somewhere in that file. Replace it with listen 8080
.
For varnish
, the listen port is part of the systemd
config file. By default it is hosted in /lib/systemd/system/varnish.service
, but it should be copied to /etc/systemd/system/varnish.service
.
In the varnish.service
file you'll find something like -a :6081
, which should be replaced by -a :80
.
After you've made the changes to the varnish.service
file, you need to reload the systemd
daemon by running sudo systemctl daemon-reload
.
And finally, it's a matter of restarting nginx
& varnish
using the restart commands that systemd
offers.
Here's the all-in-one command that does all this for you:
sudo sed -i 's/80/8080/' /etc/nginx/sites-enabled/default
sudo cp -f /lib/systemd/system/varnish.service /etc/systemd/system/varnish.service
sudo sed -i 's/-a :6081/-a :80/' /etc/systemd/system/varnish.service
sudo systemctl daemon-reload
sudo systemctl restart nginx
sudo systemctl restart varnish
These are my assumptions about these commands:
nginx
vhost conf file is /etc/nginx/sites-enabled/default
varnish
is in its out-of-the-box config, and still listens on port 6081
Upvotes: 3