http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$request_body"';
access_log /var/log/nginx/access.log main;
sendfile on;
server_tokens off;
keepalive_timeout 30;
upstream app_server {
server unix:/path.../gunicorn.sock fail_timeout=0;
}
server {
server_name exemplo.com qqcoisa.exemplo.com;
listen [::]:443 ssl http2;
listen 443 ssl http2; # managed by Certbot
access_log /path.../nginx-access.log;
error_log /path.../nginx-error.log;
client_max_body_size 1M;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_redirect off;
ssl_certificate /path.../fullchain.pem; # managed by Certbot
ssl_certificate_key /path.../privkey.pem; # managed by Certbot
include /path.../options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /path.../ssl-dhparams.pem; # managed by Certbot
# Config para Gerencianet:
ssl_client_certificate /path.../chain-pix-prod.crt;
ssl_verify_client optional;
ssl_verify_depth 3;
location /webhook {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
rewrite ^(.
)$ /webhook break;
proxy_pass http://app_server;
}
# checks for static file, if not found proxy to app
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_pass http://app_server;
}
}
}