GardenCloud & systems

Proxying an application port through Nginx

A small historical reverse-proxy example with forwarding and WebSocket-upgrade headers.

A reverse proxy can give a service a normal HTTP entry point while the application listens on another port. This older Nginx example forwarded requests and allowed a WebSocket upgrade.

server {
  listen 80;
  # The host name to respond to
  server_name app.example.com;

  location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;

    proxy_pass http://127.0.0.1:8888;

    # enable WebSockets
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

The hostname and upstream address are generic replacements for the original environment. Host and X-Forwarded-For carry request context; the upgrade headers support the protocol transition.

The server listens on HTTP port 80. This snippet does not configure TLS, authenticate clients, or establish which forwarded headers the application should trust. It records the routing pattern, not a complete deployment configuration.

← Back to the garden