Skip to content

Instantly share code, notes, and snippets.

@dotspencer
Last active April 5, 2025 16:11
Show Gist options
  • Save dotspencer/fec67dbada9764a9d6f073b1e1e7dbbc to your computer and use it in GitHub Desktop.
Save dotspencer/fec67dbada9764a9d6f073b1e1e7dbbc to your computer and use it in GitHub Desktop.
Debugging NGINX

Check to see if nginx is running:

ps aux | grep nginx

Find what process is bound to a port:

lsof -n -i:8003

tcp dump of all traffic on port

sudo tcpdump -i any port 443

For quick restarting:

sudo nginx -t && sudo nginx -s reload

For testing matching rules:

location /api {
    # proxy_pass http://localhost:8001;
    add_header Content-Type text/html;
    return 200 'api...';
}

Following error logs on Mac: tail -f /usr/local/var/log/nginx/error.log

Following error logs on Ubuntu:

tail -f /var/log/nginx/error.log

User nginx user:

ps -ef | grep nginx
@dotspencer
Copy link
Author

Useful for listing all bound ports

netstat -lnp

@dotspencer
Copy link
Author

also make sure that DNS records are pointing to the correct server

@dotspencer
Copy link
Author

you can also curl with the host locally

curl -H "Host: <example.com>" http://localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment