Linux Labs

Web stack / Stage 2 of 9

Reverse proxy and 502

Not running Starting usually ~20 s
Leave the lesson

Step 8 of 8 · summary · 2 min

Summary

  • nginx produces 502 Bad Gateway: the leg from the client to nginx worked, and the leg from nginx to the application did not.
  • nginx writes the cause on the second leg to error.log: the upstream address and a code — 111 nothing listens, 2 no socket file, 13 no permission for www-data.
  • You test the second leg separately, with a request to the application from the server itself.
  • A path after the port in proxy_pass replaces the prefix matched by location: with / the application gets the path without the prefix.
  • The shop answered 502 while it was running: nginx sent requests to port 8000, and the application listened on 8001.
Ubuntu 24.04
Loading…