75 lines
2.7 KiB
Nginx Configuration File
75 lines
2.7 KiB
Nginx Configuration File
# nginx site for Politické karty (HTTPS reverse proxy -> Docker container on 127.0.0.1:8347).
|
|
#
|
|
# 1. Replace karty.example.com with your domain (4 places below).
|
|
# 2. Install: sudo cp deploy/nginx.conf /etc/nginx/conf.d/politicke-karty.conf
|
|
# (conf.d/ and sites-enabled/ are included inside http{}, which the two *_zone lines need)
|
|
# 3. Certificates: the paths below are certbot's defaults. If you don't have a cert yet:
|
|
# sudo certbot certonly --webroot -w /var/www/html -d karty.example.com
|
|
# or point ssl_certificate / ssl_certificate_key at your own files.
|
|
# 4. sudo nginx -t && sudo systemctl reload nginx
|
|
|
|
limit_req_zone $binary_remote_addr zone=karty_api:10m rate=10r/s;
|
|
limit_conn_zone $binary_remote_addr zone=karty_conn:10m;
|
|
|
|
upstream politicke_karty {
|
|
server 127.0.0.1:8347;
|
|
keepalive 16;
|
|
}
|
|
|
|
# HTTP -> HTTPS (keeps the ACME path open for certbot renewals)
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name karty.example.com;
|
|
|
|
location /.well-known/acme-challenge/ { root /var/www/html; }
|
|
location / { return 301 https://$host$request_uri; }
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
listen [::]:443 ssl;
|
|
http2 on; # nginx >= 1.25.1; on older versions use "listen 443 ssl http2;" instead
|
|
server_name karty.example.com;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/karty.example.com/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/karty.example.com/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers off;
|
|
ssl_session_cache shared:karty_ssl:10m;
|
|
ssl_session_timeout 1d;
|
|
|
|
client_max_body_size 32k;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000" always;
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Referrer-Policy same-origin always;
|
|
add_header X-Frame-Options SAMEORIGIN always;
|
|
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
|
|
# Live game updates (Server-Sent Events): no buffering, long-lived connections.
|
|
location = /api/events {
|
|
limit_conn karty_conn 20; # simultaneous live connections per IP
|
|
proxy_pass http://politicke_karty;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_read_timeout 1h; # the app pings every 25 s
|
|
access_log off; # query string contains the player's seat token
|
|
}
|
|
|
|
location /api/ {
|
|
limit_req zone=karty_api burst=30 nodelay;
|
|
proxy_pass http://politicke_karty;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://politicke_karty;
|
|
}
|
|
}
|