Simple reverse proxy
1.1K
Simple NGINX Reverse Proxy with Dynamic Host Extraction
This Docker image sets up an NGINX proxy server that dynamically extracts and configures the host from an environment-provided URL.
$PROXY_URL environment variable and sets $PROXY_HOST for NGINX.envsubst to replace $PROXY_URL and $PROXY_HOST in the NGINX configuration file dynamically at container startup.Set Environment Variables:
$PROXY_URL: The full URL of the backend service (e.g., http://example.com).Run the Container:
docker run -e PROXY_URL=http://example.com -p 80:80 <your-image-name>
The image will automatically configure NGINX to forward requests to the provided $PROXY_URL and start NGINX in the foreground.
To start a container and proxy requests to http://backend-service:8080:
docker run -e PROXY_URL=http://backend-service:8080 -p 80:80 <your-image-name>
Host headers for proxied requests.The startup script in the container:
$PROXY_URL.$PROXY_HOST and replaces $PROXY_URL and $PROXY_HOST in the NGINX configuration.Your custom NGINX configuration template should include $PROXY_URL and $PROXY_HOST placeholders for envsubst to replace, like:
server {
listen 80;
location / {
proxy_pass $PROXY_URL;
proxy_set_header Host $PROXY_HOST;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Content type
Image
Digest
sha256:7a56e4974…
Size
5.5 MB
Last updated
about 1 month ago
docker pull kpiua/web-proxy