From 2a7d5db624fb3acde2e656875a61616b3cac761a Mon Sep 17 00:00:00 2001 From: Bastien Lacoste Date: Thu, 7 Apr 2022 12:29:27 +0200 Subject: [PATCH] nginx conf #14 HTTP/2 + #15 return --- conf/nginx/conf.d/limits.conf | 1 + conf/nginx/conf.d/websocket-connupgrade.conf | 5 ++ conf/nginx/nginx.conf | 83 +++++++++++++++++++ conf/nginx/sites-available/etherpad | 87 ++++++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 conf/nginx/conf.d/limits.conf create mode 100644 conf/nginx/conf.d/websocket-connupgrade.conf create mode 100644 conf/nginx/nginx.conf create mode 100644 conf/nginx/sites-available/etherpad diff --git a/conf/nginx/conf.d/limits.conf b/conf/nginx/conf.d/limits.conf new file mode 100644 index 0000000..48f9379 --- /dev/null +++ b/conf/nginx/conf.d/limits.conf @@ -0,0 +1 @@ +client_max_body_size 20M; diff --git a/conf/nginx/conf.d/websocket-connupgrade.conf b/conf/nginx/conf.d/websocket-connupgrade.conf new file mode 100644 index 0000000..46a463f --- /dev/null +++ b/conf/nginx/conf.d/websocket-connupgrade.conf @@ -0,0 +1,5 @@ +# we're in the http context here +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} \ No newline at end of file diff --git a/conf/nginx/nginx.conf b/conf/nginx/nginx.conf new file mode 100644 index 0000000..136753e --- /dev/null +++ b/conf/nginx/nginx.conf @@ -0,0 +1,83 @@ +user www-data; +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} + + +#mail { +# # See sample authentication script at: +# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript +# +# # auth_http localhost/auth.php; +# # pop3_capabilities "TOP" "USER"; +# # imap_capabilities "IMAP4rev1" "UIDPLUS"; +# +# server { +# listen localhost:110; +# protocol pop3; +# proxy on; +# } +# +# server { +# listen localhost:143; +# protocol imap; +# proxy on; +# } +#} diff --git a/conf/nginx/sites-available/etherpad b/conf/nginx/sites-available/etherpad new file mode 100644 index 0000000..0c040cb --- /dev/null +++ b/conf/nginx/sites-available/etherpad @@ -0,0 +1,87 @@ +server { + listen 80; + listen [::]:80; + + server_name pad.chalec.org; + root /var/www/html; + + return 301 https://$hostname$request_uri; +} + +server { + charset UTF-8; + server_name pad.chalec.org; + + listen [::]:443 ssl http2 default_server; + listen 443 http2 proxy_protocol ssl default_server; + include snippets/letsencrypt.conf; + + set_real_ip_from 192.168.1.1; + real_ip_header proxy_protocol; + + + ssi on; + ssi_last_modified on; + + + #proxy_set_header X-Real-IP $proxy_protocol_addr; + #proxy_set_header X-Forwarded-For $proxy_protocol_addr; + + root /var/www/html; + + add_header Strict-Transport-Security "max-age=31536000" always; + add_header Content-Security-Policy "default-src 'self' 'unsafe-eval' 'unsafe-inline'; object-src 'none'; connect-src 'self' wss://pad.chalec.org; frame-ancestors 'self'"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-options nosniff; + + access_log /var/log/nginx/pad.chalec.org/access.log; + error_log /var/log/nginx/pad.chalec.org/error.log warn; + + error_page 404 /404.html; + error_page 502 /502.html; + location /502.html { + root /var/www/html; + internal; + } + location /404.html { + root /var/www/html; + internal; + } + + + location /.well-known/statoolinfos { + alias /var/www/html/.well-known/statoolinfos/; + autoindex on; + } + + location / { + #proxy_protocol on; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + #proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; +# proxy_http_version 1.1; + + proxy_pass http://127.0.0.1:9001; + + proxy_buffering off; + + # WebSocket proxying - from https://nginx.org/en/docs/http/websocket.html + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } + + location /about.html { + alias /var/www/html/pad/about.html; + } + + location /logo.svg { + alias /var/www/html/pad/pad.chalec.org.svg; + } + + +} + + +