Skip to content

Commit 680c9f9

Browse files
committedJul 12, 2024··
chore: Redirect IP access
1 parent fdfe7c8 commit 680c9f9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ tmp
2020
*~
2121
.env.local*
2222
.env.testing*
23+
.env.prod*
2324
*_password.txt
2425
.secrets*
2526
*local_testing.yml

‎nginx/templates/webapp.conf.template

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ upstream backend{
66

77
# base on https://ssl-config.mozilla.org/#server=nginx&version=1.25.2&config=intermediate&openssl=3.0.9&guideline=5.7
88

9+
map $host $redirect_to_second_level {
10+
default 0;
11+
www.${SECOND_LEVEL_DOMAIN_NAME} 1;
12+
"~^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$" 1;
13+
"~^[0-9a-fA-F:]+$" 1;
14+
}
15+
916
server {
1017
listen 80 default_server;
1118
listen [::]:80 default_server;
1219

1320
server_name dev.${SECOND_LEVEL_DOMAIN_NAME} cf.${SECOND_LEVEL_DOMAIN_NAME} ${SECOND_LEVEL_DOMAIN_NAME} www.${SECOND_LEVEL_DOMAIN_NAME};
1421

15-
if ($host = www.${SECOND_LEVEL_DOMAIN_NAME}) {
22+
if ($host = $redirect_to_second_level) {
1623
return 301 https://${SECOND_LEVEL_DOMAIN_NAME}$request_uri;
1724
}
1825

@@ -48,7 +55,7 @@ server {
4855

4956
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
5057

51-
if ($host = www.${SECOND_LEVEL_DOMAIN_NAME}) {
58+
if ($host = $redirect_to_second_level) {
5259
return 301 https://${SECOND_LEVEL_DOMAIN_NAME}$request_uri;
5360
}
5461

0 commit comments

Comments
 (0)
Please sign in to comment.