0

I'm having a heck of an issue here. I have nginx & varnish installed. Configured nginx to listed on port 8080, and varnish to listen on port 80

nGinx will not start due to

Jul 06 16:26:36 host nginx[2863]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

I have grep'd my entire server to see if I can find where it could also be "extra" bound, and nothing is found.

Screenshot: http://prntscr.com/bpnxki

EDIT: I have killed the varnish process for now, then restarted nginx, and when I netstat -tlnp I can see that it is binding to both ports 80 and 8080. I need this on port 8080 only: http://prntscr.com/bpo2yl

How can I prevent nginx from binding to port 80 period?

Kevin
  • 354
  • 1
  • 4
  • 23

1 Answers1

0

You have to edit the configurations for your nginx sites under /etc/nginx/sites-enabled and change the listen directives to a different port. Or remove the sites from the enabled list. Once done and you run sudo service nginx restart, then nginx should no longer bind to those ports.

(The only other reason nginx might bind to ports and disobey the standard config is if it's not a standard setup and is, for example, an nginx that is bundled up with some other software and not following the standard configuration locations as a result.)

Thomas Ward
  • 80,112
  • I deleted both the sites-enabled and sites-available folders..., and it's a standard ubuntu nginx install. other than my own configurations which i've verified there are no port 80 bindings – Kevin Jul 06 '16 at 20:52
  • besides... wouldn't grep find the string I searched for in the first screenshot? – Kevin Jul 06 '16 at 20:54
  • And you stopped or restarted the nginx service afterwards? – Thomas Ward Jul 06 '16 at 21:05
  • It wasn't running, and when I started it, that is when the error is thrown – Kevin Jul 06 '16 at 21:10
  • 1
    I would create a configuration then in /etc/nginx/sites-enabled that listens on some bogus port you don't care about then - it's probable that nginx is attempting to bind to a port by default as per the defaults compiled into it. If you give it a different port to listen on though that may solve the issue. – Thomas Ward Jul 06 '16 at 21:11
  • Given I am on my phone I can't give you such an example right now, will do at home though after my commute. – Thomas Ward Jul 06 '16 at 21:11
  • my server does not use /etc/nginx/sites-enabled, however, when I added a listen 82;, port 80 shows still bound: http://prntscr.com/bpoknf – Kevin Jul 06 '16 at 21:16