Skip to content

Instantly share code, notes, and snippets.

@hugotkk
Created April 14, 2023 16:49
Show Gist options
  • Save hugotkk/a2e879cbda87df5138790c21bfa44739 to your computer and use it in GitHub Desktop.
Save hugotkk/a2e879cbda87df5138790c21bfa44739 to your computer and use it in GitHub Desktop.
Nginx config to serve proxy protocol v2
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
upstream backend {
server 127.0.0.1:9000;
}
server {
listen 80 proxy_protocol;
location / {
proxy_pass http://backend;
proxy_set_header Proxy-Protocol $proxy_protocol_addr;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_protocol_addr;
}
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment