@@ -17,7 +17,16 @@ func ConfigureNginxHttp(domainName string) {
17
17
18
18
directories .CreateDirectory (fmt .Sprintf ("%s/%s/%s/" , network .WWWDirPath , domainName , network .AcmeChallengeDirPath ), 0755 )
19
19
20
- configContent := fmt .Sprintf (`server {
20
+ configContent := fmt .Sprintf (`map $http_upgrade $connection_upgrade {
21
+ default upgrade;
22
+ '' close;
23
+ }
24
+
25
+ upstream strfry_websocket {
26
+ server 127.0.0.1:7777;
27
+ }
28
+
29
+ server {
21
30
listen 80;
22
31
listen [::]:80;
23
32
server_name %s;
@@ -28,15 +37,17 @@ func ConfigureNginxHttp(domainName string) {
28
37
}
29
38
30
39
location / {
31
- # First attempt to serve request as file, then
32
- # as directory, then fall back to displaying 404.
33
- try_files $uri $uri/ =404;
34
- proxy_pass http://127.0.0.1:7777;
40
+ proxy_pass http://strfry_websocket;
35
41
proxy_http_version 1.1;
36
42
proxy_set_header Upgrade $http_upgrade;
37
- proxy_set_header Connection "upgrade" ;
43
+ proxy_set_header Connection $connection_upgrade ;
38
44
proxy_set_header Host $host;
39
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45
+ proxy_set_header X-Real-IP $remote_addr;
46
+ proxy_set_header X-Forwarded-For $remote_addr;
47
+ proxy_set_header X-Forwarded-Proto $scheme;
48
+ # First attempt to serve request as file, then
49
+ # as directory, then fall back to displaying 404.
50
+ try_files $uri $uri/ =404;
40
51
}
41
52
42
53
# Only return Nginx in server header
@@ -49,11 +60,11 @@ func ConfigureNginxHttp(domainName string) {
49
60
add_header X-Frame-Options DENY;
50
61
51
62
# Avoid MIME type sniffing
52
- add_header X-Content-Type-Options nosniff always;
63
+ add_header X-Content-Type-Options " nosniff" always;
53
64
54
65
add_header Referrer-Policy "no-referrer" always;
55
66
56
- add_header X-XSS-Protection 0 always;
67
+ add_header X-XSS-Protection "1; mode=block" always;
57
68
58
69
add_header Permissions-Policy "geolocation=(), midi=(), sync-xhr=(), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(self), payment=()" always;
59
70
0 commit comments