0

I am trying to work this out for hours.

I installed varnish and set the port to 80. After that, I changed the listen directive of my nginx virtualhost files from 80 to 8080:

listen 8080;

However, the page is being redirected indefinitely. When I check the port binding, one strange thing I found out was nginx is listening to both port 80 & 8080, and varnish is also listening to 80.

$ sudo lsof -P -n -i :80 -i :8080 -i :443 | grep LISTEN
nginx    8433     root    6u  IPv4 2401466757      0t0  TCP *:80 (LISTEN)
nginx    8433     root    7u  IPv4 2401466758      0t0  TCP *:8080 (LISTEN)
nginx    8436 www-data    6u  IPv4 2401466757      0t0  TCP *:80 (LISTEN)
nginx    8436 www-data    7u  IPv4 2401466758      0t0  TCP *:8080 (LISTEN)
nginx    8437 www-data    6u  IPv4 2401466757      0t0  TCP *:80 (LISTEN)
nginx    8437 www-data    7u  IPv4 2401466758      0t0  TCP *:8080 (LISTEN)
nginx    8438 www-data    6u  IPv4 2401466757      0t0  TCP *:80 (LISTEN)
nginx    8438 www-data    7u  IPv4 2401466758      0t0  TCP *:8080 (LISTEN)
nginx    8439 www-data    6u  IPv4 2401466757      0t0  TCP *:80 (LISTEN)
nginx    8439 www-data    7u  IPv4 2401466758      0t0  TCP *:8080 (LISTEN)
varnishd 8520   nobody    8u  IPv6 2401837251      0t0  TCP *:80 (LISTEN)

As far as I know, nginx should only listen to port 8080 and varnish should only listen to port 80. But why is this happening?

NOTE

  • No any firewall, like ufw, is installed.
  • there is no any listen 80; left in any of the configuration files.
  • System is ubuntu
  • No Default configuration file present anywhere inside nginx folder
  • Post configurations of both, and logs that show the behavior when you hit Varnish and again when you hit Nginx directly. – Tim Sep 28 '16 at 17:53
0

Most likely you have /etc/nginx/conf.d/default.conf which is present on rpm based installations. It has default host which listens on port 80. Best practice is to trim that file so that further upgrades will not replace it.

  • There is no any default configuration file anywhere inside nginx folder, and the system is ubuntu. – uvishere Sep 28 '16 at 17:50
  • You may have a server block where listen directive is absent or commented. That will cause it listen on port 80 by default. So you need to make sure each server block has a listen directive with the port other than 80. Additionally. have you restarted nginx to apply your changes? :) – Danila Vershinin Sep 28 '16 at 19:30

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.