0

I have nginx running as a web server. The virtual host have the IP specific configuration with IP addresses listed, however whtn I check netstat Nginx is litening on 0.0.0.0:80. I would like to change this to a specific IP. The server has 2 network connections, one public and one private. I do not want nginx on the private address, just the public.

Is there something in the nginx.conf that I can add to specify an IP address or interface where should it listen on?

I know there are the Virtual hosts where I can add them by ip, but that would not change nginx itself from listening only on a certain IP. It would be still 0.0.0.0:80 for example.

Thanks!

Tibby
  • 215
  • 1
  • 3
  • 9
  • Try https://stackoverflow.com/questions/13634574/how-to-make-nginx-to-listen-to-server-nameport (Apparently I can't duplicate this to the SO post, which should theoretically be here in Serverfault) – ewokx Sep 09 '22 at 04:49
  • Why do not reading documentation for such simple thing? There is google searching, ngnix documentation, why not? – gapsf Sep 09 '22 at 04:53
  • https://docs.nginx.com/search.html#q=Listen&sort=relevancy – gapsf Sep 09 '22 at 05:18
  • So the issue is again NOT the virtual host not having an IP address and needed to set the "Listen" directive on the virual host. The problem is that NginX itself was listening on all IPs even if the Virtual hosts had IPs listed. I Coudl not find it anywhere that would say if there is just one host file that has no ip address, just port specified, then Nginx will listen on every interfaces and every IP addresses. Again I know how to set the IP for the virtual hosts. I was looking if there was something to set the IP and Interface for Nginx itself in the nginx.conf or somewhere else. – Tibby Sep 16 '22 at 05:14

1 Answers1

0

Just got it figured out. The default host file only has port 80 listed as listen. Once I've changed and added the IP to it, netstat is showing the correct ip, not 0.0.0.0:80 anymore.

Tibby
  • 215
  • 1
  • 3
  • 9