Skip to content

Commit a7b78f8

Browse files
authored
chore: move nginx root directive to server block and replace allow all in location block with expected certbot default type #27 (#73)
1 parent a9f6da9 commit a7b78f8

File tree

12 files changed

+84
-48
lines changed

12 files changed

+84
-48
lines changed

pkg/relays/khatru29/nginx_http.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ server {
3434
listen [::]:80;
3535
server_name %s;
3636
37+
root %s/%s;
38+
3739
location /%s/ {
38-
root %s/%s;
39-
allow all;
40+
default_type "text/plain";
4041
}
4142
4243
location / {
@@ -80,11 +81,13 @@ server {
8081
listen [::]:443 ssl http2;
8182
server_name %s;
8283
84+
root %s/%s;
85+
8386
location / {
8487
return 301 http://%s$request_uri;
8588
}
8689
}
87-
`, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName, domainName)
90+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, domainName, network.WWWDirPath, domainName, domainName)
8891

8992
files.WriteFile(NginxConfigFilePath, configContent, 0644)
9093
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/khatru29/nginx_https.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ server {
2929
listen [::]:443 ssl http2;
3030
server_name %s;
3131
32+
root %s/%s;
33+
34+
location /%s/ {
35+
default_type "text/plain";
36+
}
37+
3238
location / {
3339
proxy_pass http://khatru29_websocket;
3440
proxy_http_version 1.1;
@@ -111,16 +117,13 @@ server {
111117
listen [::]:80;
112118
server_name %s;
113119
114-
location /%s/ {
115-
root %s/%s;
116-
allow all;
117-
}
120+
root %s/%s;
118121
119122
location / {
120123
return 301 https://%s$request_uri;
121124
}
122125
}
123-
`, domainName, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName)
126+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
124127

125128
files.WriteFile(NginxConfigFilePath, configContent, 0644)
126129
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/khatru_pyramid/nginx_http.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ server {
3434
listen [::]:80;
3535
server_name %s;
3636
37+
root %s/%s;
38+
3739
location /%s/ {
38-
root %s/%s;
39-
allow all;
40+
default_type "text/plain";
4041
}
4142
4243
location / {
@@ -80,11 +81,13 @@ server {
8081
listen [::]:443 ssl http2;
8182
server_name %s;
8283
84+
root %s/%s;
85+
8386
location / {
8487
return 301 http://%s$request_uri;
8588
}
8689
}
87-
`, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName, domainName)
90+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, domainName, network.WWWDirPath, domainName, domainName)
8891

8992
files.WriteFile(NginxConfigFilePath, configContent, 0644)
9093
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/khatru_pyramid/nginx_https.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ server {
2929
listen [::]:443 ssl http2;
3030
server_name %s;
3131
32+
root %s/%s;
33+
34+
location /%s/ {
35+
default_type "text/plain";
36+
}
37+
3238
location / {
3339
proxy_pass http://khatru_pyramid_websocket;
3440
proxy_http_version 1.1;
@@ -111,16 +117,13 @@ server {
111117
listen [::]:80;
112118
server_name %s;
113119
114-
location /%s/ {
115-
root %s/%s;
116-
allow all;
117-
}
120+
root %s/%s;
118121
119122
location / {
120123
return 301 https://%s$request_uri;
121124
}
122125
}
123-
`, domainName, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName)
126+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
124127

125128
files.WriteFile(NginxConfigFilePath, configContent, 0644)
126129
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/nostr_rs_relay/nginx_http.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ server {
3434
listen [::]:80;
3535
server_name %s;
3636
37+
root %s/%s;
38+
3739
location /%s/ {
38-
root %s/%s;
39-
allow all;
40+
default_type "text/plain";
4041
}
4142
4243
location / {
@@ -80,11 +81,13 @@ server {
8081
listen [::]:443 ssl http2;
8182
server_name %s;
8283
84+
root %s/%s;
85+
8386
location / {
8487
return 301 http://%s$request_uri;
8588
}
8689
}
87-
`, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName, domainName)
90+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, domainName, network.WWWDirPath, domainName, domainName)
8891

8992
files.WriteFile(NginxConfigFilePath, configContent, 0644)
9093
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/nostr_rs_relay/nginx_https.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ server {
2929
listen [::]:443 ssl http2;
3030
server_name %s;
3131
32+
root %s/%s;
33+
34+
location /%s/ {
35+
default_type "text/plain";
36+
}
37+
3238
location / {
3339
proxy_pass http://nostr_rs_relay_websocket;
3440
proxy_http_version 1.1;
@@ -111,16 +117,13 @@ server {
111117
listen [::]:80;
112118
server_name %s;
113119
114-
location /%s/ {
115-
root %s/%s;
116-
allow all;
117-
}
120+
root %s/%s;
118121
119122
location / {
120123
return 301 https://%s$request_uri;
121124
}
122125
}
123-
`, domainName, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName)
126+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
124127

125128
files.WriteFile(NginxConfigFilePath, configContent, 0644)
126129
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/strfry/nginx_http.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ server {
3434
listen [::]:80;
3535
server_name %s;
3636
37+
root %s/%s;
38+
3739
location /%s/ {
38-
root %s/%s;
39-
allow all;
40+
default_type "text/plain";
4041
}
4142
4243
location / {
@@ -80,11 +81,13 @@ server {
8081
listen [::]:443 ssl http2;
8182
server_name %s;
8283
84+
root %s/%s;
85+
8386
location / {
8487
return 301 http://%s$request_uri;
8588
}
8689
}
87-
`, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName, domainName)
90+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, domainName, network.WWWDirPath, domainName, domainName)
8891

8992
files.WriteFile(NginxConfigFilePath, configContent, 0644)
9093
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/strfry/nginx_https.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ server {
2929
listen [::]:443 ssl http2;
3030
server_name %s;
3131
32+
root %s/%s;
33+
34+
location /%s/ {
35+
default_type "text/plain";
36+
}
37+
3238
location / {
3339
proxy_pass http://strfry_websocket;
3440
proxy_http_version 1.1;
@@ -111,16 +117,13 @@ server {
111117
listen [::]:80;
112118
server_name %s;
113119
114-
location /%s/ {
115-
root %s/%s;
116-
allow all;
117-
}
120+
root %s/%s;
118121
119122
location / {
120123
return 301 https://%s$request_uri;
121124
}
122125
}
123-
`, domainName, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName)
126+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
124127

125128
files.WriteFile(NginxConfigFilePath, configContent, 0644)
126129
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/strfry29/nginx_http.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ server {
3434
listen [::]:80;
3535
server_name %s;
3636
37+
root %s/%s;
38+
3739
location /%s/ {
38-
root %s/%s;
39-
allow all;
40+
default_type "text/plain";
4041
}
4142
4243
location / {
@@ -80,11 +81,13 @@ server {
8081
listen [::]:443 ssl http2;
8182
server_name %s;
8283
84+
root %s/%s;
85+
8386
location / {
8487
return 301 http://%s$request_uri;
8588
}
8689
}
87-
`, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName, domainName)
90+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, domainName, network.WWWDirPath, domainName, domainName)
8891

8992
files.WriteFile(NginxConfigFilePath, configContent, 0644)
9093
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/strfry29/nginx_https.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ server {
2929
listen [::]:443 ssl http2;
3030
server_name %s;
3131
32+
root %s/%s;
33+
34+
location /%s/ {
35+
default_type "text/plain";
36+
}
37+
3238
location / {
3339
proxy_pass http://strfry29_websocket;
3440
proxy_http_version 1.1;
@@ -111,16 +117,13 @@ server {
111117
listen [::]:80;
112118
server_name %s;
113119
114-
location /%s/ {
115-
root %s/%s;
116-
allow all;
117-
}
120+
root %s/%s;
118121
119122
location / {
120123
return 301 https://%s$request_uri;
121124
}
122125
}
123-
`, domainName, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName)
126+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
124127

125128
files.WriteFile(NginxConfigFilePath, configContent, 0644)
126129
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/wot_relay/nginx_http.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ server {
3434
listen [::]:80;
3535
server_name %s;
3636
37+
root %s/%s;
38+
3739
location /%s/ {
38-
root %s/%s;
39-
allow all;
40+
default_type "text/plain";
4041
}
4142
4243
location / {
@@ -80,11 +81,13 @@ server {
8081
listen [::]:443 ssl http2;
8182
server_name %s;
8283
84+
root %s/%s;
85+
8386
location / {
8487
return 301 http://%s$request_uri;
8588
}
8689
}
87-
`, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName, domainName)
90+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, domainName, network.WWWDirPath, domainName, domainName)
8891

8992
files.WriteFile(NginxConfigFilePath, configContent, 0644)
9093
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

pkg/relays/wot_relay/nginx_https.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ server {
2929
listen [::]:443 ssl http2;
3030
server_name %s;
3131
32+
root %s/%s;
33+
34+
location /%s/ {
35+
default_type "text/plain";
36+
}
37+
3238
location / {
3339
proxy_pass http://wot_relay_websocket;
3440
proxy_http_version 1.1;
@@ -111,16 +117,13 @@ server {
111117
listen [::]:80;
112118
server_name %s;
113119
114-
location /%s/ {
115-
root %s/%s;
116-
allow all;
117-
}
120+
root %s/%s;
118121
119122
location / {
120123
return 301 https://%s$request_uri;
121124
}
122125
}
123-
`, domainName, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.AcmeChallengeDirPath, network.WWWDirPath, domainName, domainName)
126+
`, domainName, network.WWWDirPath, domainName, network.AcmeChallengeDirPath, network.CertificateDirPath, domainName, network.FullchainFile, network.CertificateDirPath, domainName, network.PrivkeyFile, network.CertificateDirPath, domainName, network.ChainFile, domainName, network.WWWDirPath, domainName, domainName)
124127

125128
files.WriteFile(NginxConfigFilePath, configContent, 0644)
126129
files.SetOwnerAndGroup(relays.NginxUser, relays.NginxUser, NginxConfigFilePath)

0 commit comments

Comments
 (0)