Skip to content

Commit 3a7cb1f

Browse files
committed
chore(infra): Add permanent redirect to the new domain
1 parent 33a9c88 commit 3a7cb1f

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

nginx/nginx.conf

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,69 @@ http {
1616
include /etc/nginx/mime.types;
1717
default_type application/octet-stream;
1818

19-
sendfile on;
19+
sendfile on;
2020
keepalive_timeout 65;
2121

2222
gzip on;
2323
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
2424

25+
# ───────── 1) Redirect herokuapp host -> canonical domain ─────────
2526
server {
2627
listen $PORT;
27-
listen [::]:$PORT;
28+
listen [::]:$PORT;
29+
server_name wetlands-gap-map-staging-b3fdd14996a5.herokuapp.com www.wetlands-gap-map-staging-b3fdd14996a5.herokuapp.com;
30+
31+
return 301 https://gaps-staging.wetlands.org$request_uri;
32+
}
33+
34+
# ───────── 2) App server for gaps-staging.wetlands.org ─────────
35+
server {
36+
listen $PORT;
37+
listen [::]:$PORT;
38+
server_name gaps-staging.wetlands.org www.gaps-staging.wetlands.org;
2839

2940
client_max_body_size 50m;
3041

42+
# Common proxy settings (Heroku terminates TLS; preserve proto/host)
43+
# Use these in each location:
44+
# - keep Host as sent by the client
45+
# - forward the proto from Heroku router to avoid HTTPS loops
46+
# - keep real client IP chain
47+
# - support websockets/Next.js dev features if used
48+
# (Duplicated in each location for clarity)
49+
3150
# ───── Proxy tiler (Tile Server) ─────
3251
location /tiler {
3352
proxy_pass http://localhost:8000;
34-
proxy_set_header Host $host;
35-
proxy_set_header X-Real-IP $remote_addr;
36-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
53+
54+
proxy_set_header Host $host;
55+
proxy_set_header X-Forwarded-Host $host;
56+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
57+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
58+
proxy_set_header X-Real-IP $remote_addr;
59+
3760
proxy_http_version 1.1;
61+
proxy_set_header Upgrade $http_upgrade;
62+
proxy_set_header Connection $connection_upgrade;
63+
64+
proxy_redirect off;
3865
}
3966

4067
# ───── Proxy Admin UI & Next.js Frontend ─────
4168
location / {
4269
proxy_pass http://localhost:3000;
43-
proxy_set_header Host $host;
44-
proxy_set_header X-Real-IP $remote_addr;
45-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
70+
71+
proxy_set_header Host $host;
72+
proxy_set_header X-Forwarded-Host $host;
73+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
74+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
75+
proxy_set_header X-Real-IP $remote_addr;
76+
4677
proxy_http_version 1.1;
78+
proxy_set_header Upgrade $http_upgrade;
79+
proxy_set_header Connection $connection_upgrade;
80+
81+
proxy_redirect off;
4782
}
4883
}
4984
}

0 commit comments

Comments
 (0)