0

nginx on Mac OS X is running via brew successfully on ports 80 and 443.

However, I am trying to run on a different port 18000 and nginx does not want to respond, despite listening to the port.

server {
    listen       18000 ssl;
    server_name  example.com www.example.com;

    location / {
        proxy_pass       https://www.new-server.com/;
        proxy_redirect   https://www.new-server.com https://www.example.com;
}

I can see the port is being listening on netstat -na | grep LISTEN | grep 18000:

tcp4       0      0  *.18000                *.*                    LISTEN 

sudo lsof -i :18000 shows the port is being listened on as well by nginx:

nginx     71351       root   11u  IPv4 0x78e8667283110347      0t0  TCP *:18000 (LISTEN)
nginx     71359     nobody   11u  IPv4 0x78e8667282110647      0t0  TCP *:18000 (LISTEN)

Yet the access logs do not show anything when I run curl -k https://example.com:18000. Nothing shows up in the error log when I start up nginx after setting the config above.

How can I further debug this?

  • What does `curl -v -k https://example.com:18000` produce? – Mark Wagner Feb 15 '20 at 00:10
  • 2
    Have you configured DNS or /etc/hosts to resolve example.com to your host? – Alexey Ten Feb 15 '20 at 07:02
  • @AlexeyTen ah, good point - I was not doing this. `nginx` only handles requests to local server, and my requests were not even hitting `nginx` at all because the DNS was resolving to the normal IP address. For some reason I was thinking `nginx` was handling requests _before_ they were resolved. Good catch. – Adam Thompson Mar 02 '20 at 21:30

0 Answers0