hedgedocs-nginx.conf.j2 2.38 KB
Newer Older
nono's avatar
nono committed
1
2
# {{ ansible_managed }}

nono's avatar
nono committed
3
4
5
6
7
map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}
server {
nono's avatar
nono committed
8
9
10
11

    server_name {{ service_hedgedocs_domain }};

    location / {
nono's avatar
nono committed
12
            proxy_pass http://127.0.0.1:3003;
nono's avatar
nono committed
13
14
15
16
17
18
19
            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;
    }

    location /socket.io/ {
nono's avatar
nono committed
20
            proxy_pass http://127.0.0.1:3003;
nono's avatar
nono committed
21
22
23
24
25
26
27
            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_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
    }
nono's avatar
nono committed
28
29
30

    listen [::]:443 ssl http2;
    listen 443 ssl http2;
nono's avatar
nono committed
31

nono's avatar
nono committed
32
33
34
35
36
37
38
    # Errors
    access_log /var/log/nginx/hedgedocs_access.log;
    error_log /var/log/nginx/hedgedocs_error.log warn;

    # SSL
    ssl_certificate /etc/letsencrypt/live/{{ service_hedgedocs_domain }}/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/{{ service_hedgedocs_domain }}/privkey.pem;
nono's avatar
nono committed
39
40
41
42
43
44
45
46
47
48
49

  	# Improve HTTPS performance with session resumption
  	ssl_session_cache shared:SSL:10m;
  	ssl_session_timeout 10m;

	# Enable server-side protection against BEAST attacks
  	ssl_protocols TLSv1.2;
	ssl_prefer_server_ciphers on;
	ssl_ciphers "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384";

    # RFC-7919 recommended: https://wiki.mozilla.org/Security/Server_Side_TLS#ffdhe4096
nono's avatar
nono committed
50
    ssl_dhparam /etc/ssl/ffdhe2048.pem;
nono's avatar
nono committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    ssl_ecdh_curve secp521r1:secp384r1;

	# Aditional Security Headers
	# ref: https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
	add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

	# ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
	add_header X-Frame-Options DENY always;

	# ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
	add_header X-Content-Type-Options nosniff always;

	# ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
	add_header X-Xss-Protection "1; mode=block" always;
nono's avatar
nono committed
65
}