Sign inSign up

kpiua/web-proxy

By kpiua

•Updated about 1 month ago

Simple reverse proxy

Image
Developer tools
Web servers
0

1.1K

kpiua/web-proxy repository overview

⁠web-proxy

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.

⁠Features
  • Automatic Host Extraction: Automatically extracts the host from the $PROXY_URL environment variable and sets $PROXY_HOST for NGINX.
  • Environment Variable Substitution: Uses envsubst to replace $PROXY_URL and $PROXY_HOST in the NGINX configuration file dynamically at container startup.
  • Customizable Proxy Configuration: Easily adapt proxy settings by modifying the NGINX configuration template.
⁠Usage
  1. Set Environment Variables:

    • $PROXY_URL: The full URL of the backend service (e.g., http://example.com).
  2. 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.

⁠Example

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>
⁠Environment Variables
  • PROXY_URL: Full URL of the target backend. The container will automatically extract the host portion to configure Host headers for proxied requests.
⁠Configuration Details

The startup script in the container:

  1. Extracts the host from $PROXY_URL.
  2. Sets $PROXY_HOST and replaces $PROXY_URL and $PROXY_HOST in the NGINX configuration.
  3. Starts NGINX.
⁠Example 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;
    }
}

Tag summary

Content type

Image

Digest

sha256:7a56e4974…

Size

5.5 MB

Last updated

about 1 month ago

docker pull kpiua/web-proxy