>_ IzzyLab

Hands-on task

This task is step 9 of the course “nginx basics”

nginx proxies into the void

medium~5 min

nginx on port 80 is set up as a proxy to an application (proxy_pass http://127.0.0.1:9000), but http://localhost/ returns 502 Bad Gateway — the application itself isn't running. Bring up the application from /opt/backend/start.sh so the page is served.

What you'll practise:
  • nginx
  • proxy_pass
  • 502
  • troubleshooting
  • background processes

Topic breakdown

A 502 Bad Gateway error from nginx means the proxy itself is alive but couldn't reach the upstream — this separates a backend problem from a config problem (403/404 nginx returns itself). Diagnosis proceeds from the logs (/var/log/nginx/error.log) and from checking who is listening on the upstream port (ss/netstat). The key nuance of starting a daemon by hand: a process left in the foreground will die together with the session — you need to detach it from the terminal and send it into the background with something like setsid/nohup/disown.

What's checked

  1. Site serves the application's response

What it looks like