# DoS Mitigation limit_req_zone $binary_remote_addr zone=one:10m rate=3r/m; limit_conn_zone $binary_remote_addr zone=addr:10m; {% if be_app_repo is defined %} upstream puma { server unix:{{puma_sockfile}} fail_timeout=0; } {% endif %} server { listen 80; return 301 https://$host$request_uri; } server { listen 443 http2 default_server; listen [::]:443 ssl http2 default_server; {% if letsencrypt.hostname %} server_name {{ letsencrypt.hostname }}; {% endif %} ssl on; {% if letsencrypt.enabled %} ssl_certificate /etc/letsencrypt/live/{{ letsencrypt.hostname }}/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/{{ letsencrypt.hostname }}/privkey.pem; {% else %} ssl_certificate /etc/nginx/ssl/self-signed.crt; ssl_certificate_key /etc/nginx/ssl/self-signed.key; {% endif %} ssl_dhparam /etc/nginx/ssl/dhparam.pem; ssl_protocols TLSv1.1 TLSv1.2; ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; ssl_prefer_server_ciphers on; ssl_ecdh_curve secp384r1; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; add_header Strict-Transport-Security "max-age=31536000; preload" ; ssl_session_timeout 2h; ssl_stapling on; ssl_stapling_verify on; resolver 8.8.8.8 8.8.4.4 valid=300s; resolver_timeout 5s; add_header X-Frame-Options "DENY"; add_header Public-Key-Pins 'pin-sha256="klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY="; pin-sha256="633lt352PKRXbOwf4xSEa1M517scpD3l5f79xMD9r9Q="; max-age=2592000; includeSubDomains'; # DoS Mitigation client_body_timeout 5s; client_header_timeout 5s; {% if fe_app_repo is defined%} root {{ fe_app_path }}/dist; {% else %} root {{ be_app_path }}/public; {% endif %} if (-f $document_root/system/maintenance.html) { return 503; } error_page 503 @maintenance; location @maintenance { rewrite ^(.*)$ /system/maintenance.html last; break; } location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; root {{ be_app_path }}/public; } {% if be_app_repo is defined %} try_files $uri/index.html $uri @puma; location @puma { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://puma; } {% endif %} error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; if (-f $document_root/system/maintenance.html) { return 503; } error_page 503 @maintenance; location @maintenance { rewrite ^(.*)$ /system/maintenance.html last; break; } }