@@ -30,12 +30,17 @@ upstream websocket {
30
30
}
31
31
32
32
server {
33
- listen 443 ssl;
34
- listen [::]:443 ssl;
33
+ listen 443 ssl http2 ;
34
+ listen [::]:443 ssl http2 ;
35
35
server_name %s;
36
36
37
+ root /var/www/%s;
38
+
37
39
location / {
38
- proxy_pass http://websocket;
40
+ # First attempt to serve request as file, then
41
+ # as directory, then fall back to displaying 404.
42
+ try_files $uri $uri/ =404;
43
+ proxy_pass http://websocket;
39
44
proxy_http_version 1.1;
40
45
proxy_set_header Upgrade $http_upgrade;
41
46
proxy_set_header Connection $connection_upgrade;
@@ -44,24 +49,66 @@ server {
44
49
}
45
50
46
51
#### SSL Configuration ####
52
+ # Test configuration:
53
+ # https://www.ssllabs.com/ssltest/analyze.html
54
+ # https://cryptcheck.fr/
47
55
ssl_certificate /etc/letsencrypt/live/%s/fullchain.pem;
48
56
ssl_certificate_key /etc/letsencrypt/live/%s/privkey.pem;
57
+ # Verify chain of trust of OCSP response using Root CA and Intermediate certs
58
+ ssl_trusted_certificate /etc/letsencrypt/live/%s/chain.pem;
49
59
50
- ssl_session_cache shared:SSL:10m;
51
- ssl_session_timeout 10m;
52
- ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
60
+ # Only return Nginx in server header
61
+ server_tokens off;
62
+
63
+ # TODO
64
+ # Add support to generate the file in the script
65
+ #ssl_dhparam /etc/ssl/certs/dhparam.pem;
66
+
67
+ ssl_protocols TLSv1.2 TLSv1.3;
68
+
69
+ # For more information on the security of different cipher suites, you can refer to the following link:
70
+ # https://ciphersuite.info/
71
+ # Compilation of the top cipher suites 2024:
72
+ # https://ssl-config.mozilla.org/#server=nginx
73
+ ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305";
74
+
75
+ # Perfect Forward Secrecy (PFS) is frequently compromised without this
53
76
ssl_prefer_server_ciphers on;
54
- ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
77
+
78
+ ssl_session_tickets off;
79
+
80
+ # Enable SSL session caching for improved performance
81
+ # Try setting ssl_session_timeout to 1d if performance is bad
82
+ ssl_session_timeout 10m;
83
+ ssl_session_cache shared:SSL:10m;
84
+
85
+ # By default, the buffer size is 16k, which corresponds to minimal overhead when sending big responses.
86
+ # To minimize Time To First Byte it may be beneficial to use smaller values
87
+ ssl_buffer_size 8k;
88
+
89
+ # OCSP stapling
55
90
ssl_stapling on;
56
91
ssl_stapling_verify on;
57
- ssl_ecdh_curve secp384r1;
58
92
59
- add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
93
+ # Security headers
94
+ # Test configuration:
95
+ # https://securityheaders.com/
96
+ # https://observatory.mozilla.org/
97
+ add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
98
+
60
99
add_header X-Frame-Options DENY;
61
- add_header X-Content-Type-Options nosniff;
62
- add_header X-XSS-Protection "1; mode=block";
63
- add_header Referrer-Policy same-origin;
64
- add_header Feature-Policy "geolocation none;midi none;notifications none;push none;sync-xhr none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;";
100
+
101
+ # Avoid MIME type sniffing
102
+ add_header X-Content-Type-Options nosniff always;
103
+
104
+ add_header Referrer-Policy "no-referrer" always;
105
+
106
+ add_header X-XSS-Protection 0 always;
107
+
108
+ add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(self), payment=()" always;
109
+
110
+ # Content-Security-Policy (CSP)
111
+ add_header Content-Security-Policy "base-uri 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests;" always;
65
112
}
66
113
67
114
server {
@@ -78,7 +125,7 @@ server {
78
125
return 301 https://%s$request_uri;
79
126
}
80
127
}
81
- ` , domainName , domainName , domainName , domainName , dirName , domainName )
128
+ ` , domainName , dirName , domainName , domainName , domainName , domainName , dirName , domainName )
82
129
83
130
err = os .WriteFile ("/etc/nginx/conf.d/nostr_relay.conf" , []byte (configContent ), 0644 )
84
131
if err != nil {
0 commit comments