A basic reverse proxy designed to simplify header manipulation.
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
.
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"';
...
}
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;
}
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;
}
...
}
To change how logging is configured, mount a file at /etc/nginx/log.conf
:
access_log off;
error_log off;
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.
A health check is available on port 18081
at /healthz
.