Skip to content

Latest commit

 

History

History
93 lines (66 loc) · 1.96 KB

README.md

File metadata and controls

93 lines (66 loc) · 1.96 KB

Docker Nginx Proxy

A basic reverse proxy designed to simplify header manipulation.

Usage

To configure the upstream, create an app.conf with a server block:

server {
    listen 8080;

    location / {
        proxy_pass http://app:80;
    }
}

The file must be placed in /etc/nginx.

Header manipulation

Within the server block you can maniplate headers using the headers-more module:

server {
    ...

    # Remove a header
    more_clear_headers "Server";

    # Set a header
    more_set_headers 'X-Robots-Tag: "noindex, nofollow"';

    ...
}

Tracing

Add observability by enabling trace propagation and sending telemetry data to an OTel collector:

otel_trace          on;
otel_service_name   example_service:nginx;
otel_trace_context  propagate;
otel_exporter {
    endpoint        otel-collector:4317;
    interval        5s;
    batch_size      512;
    batch_count     4;
}

Further customisation

Since you're defining a standard server block, you can configure it however you like over and above just header manipulation. For example, you can add a custom location:

server {
    ...

    # Use the default robots.txt to disallow all bots
    location /robots.txt {
        alias /etc/nginx/robots.txt;
    }

    ...
}

Logging

To change how logging is configured, mount a file at /etc/nginx/log.conf:

access_log off;
error_log off;

Core configuration

It's also possible to modify core configuration such as those in the main section by mounting a file at /etc/nginx/main.conf:

worker_processes auto;
worker_shutdown_timeout 300s;

It's important to note that overriding this file will remove the current defaults hence it's always a good idea to start with a copy of the defaults.

Health check

A health check is available on port 18081 at /healthz.