58 lines
1.9 KiB
Plaintext
58 lines
1.9 KiB
Plaintext
# PostfixAdmin-RS behind nginx with TLS.
|
|
# In config.toml set: trusted_proxies = ["127.0.0.1", "::1"], cookie_secure = true, hsts = true
|
|
#
|
|
# Serving under a sub-path (e.g. https://mail.example.com/postfixadmin/) also works:
|
|
# set base_path = "/postfixadmin" in config.toml and use `location /postfixadmin/`
|
|
# with `proxy_pass http://127.0.0.1:8080;` (no trailing slash).
|
|
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name admin.example.com;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
listen [::]:443 ssl;
|
|
http2 on;
|
|
server_name admin.example.com;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/admin.example.com/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/admin.example.com/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers off;
|
|
ssl_session_cache shared:SSL:10m;
|
|
|
|
client_max_body_size 4m;
|
|
server_tokens off;
|
|
|
|
# Optional: restrict the panel to known networks.
|
|
# allow 203.0.113.0/24;
|
|
# deny all;
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8080;
|
|
proxy_http_version 1.1;
|
|
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 $scheme;
|
|
proxy_read_timeout 90s;
|
|
}
|
|
|
|
# Slow down credential stuffing in addition to the built-in rate limit.
|
|
location = /api/auth/login {
|
|
limit_req zone=pa_login burst=5 nodelay;
|
|
proxy_pass http://127.0.0.1:8080;
|
|
proxy_http_version 1.1;
|
|
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 $scheme;
|
|
}
|
|
}
|
|
|
|
# Put this into the http {} block (e.g. /etc/nginx/conf.d/postfixadmin-rs-limits.conf):
|
|
# limit_req_zone $binary_remote_addr zone=pa_login:10m rate=10r/m;
|