Sign inSign up

s4l3h1/nginx-fwd

By s4l3h1

•Updated 5 months ago

Image
0

2.1K

s4l3h1/nginx-fwd repository overview

⁠nginx-fwd

A minimal Docker image that runs nginx as a reverse proxy / TCP forwarder. Configuration is fully driven by environment variables at container startup — no config files to edit.

⁠How it works

On start, entrypoint.sh uses envsubst to render nginx.conf.template into a live nginx config, then launches nginx in the foreground. The resulting proxy:

  • Listens on port 80
  • Forwards all traffic to UPSTREAM_URL
  • Sets the Host header to PROXY_HOST
  • Supports WebSocket upgrades
  • Exposes a /healthz endpoint that returns 200 ok
  • Uses long timeouts (24 h) suitable for persistent connections

⁠Required environment variables

VariableDescriptionExample
UPSTREAM_URLFull URL of the upstream serverhttp://1.1.1.1:80
PROXY_HOSTValue for the Host header sent upstreamexample.com

The container will refuse to start if either variable is missing.

⁠Usage

docker run -p 80:80 \
  -e UPSTREAM_URL=http://10.0.0.1:3000 \
  -e PROXY_HOST=myapp.internal \
  nginx-fwd
⁠Build
docker build -t nginx-fwd .
⁠Health check
curl http://localhost:80/healthz
# ok

⁠Docker Compose example

services:
  proxy:
    build: .
    ports:
      - "80:80"
    environment:
      UPSTREAM_URL: http://backend:3000
      PROXY_HOST: backend

Tag summary

Content type

Image

Digest

sha256:5c4b5b823…

Size

26.1 MB

Last updated

5 months ago

docker pull s4l3h1/nginx-fwd