1- user root ;
1+ # (Optional) You can remove this line to avoid the warning on Heroku:
2+ # user root;
3+
24worker_processes 1;
35worker_rlimit_nofile 4096 ;
46
@@ -16,34 +18,67 @@ http {
1618 include /etc/nginx/mime.types ;
1719 default_type application/octet-stream ;
1820
19- sendfile on;
21+ sendfile on;
2022 keepalive_timeout 65 ;
2123
2224 gzip on;
2325 gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
2426
27+ # Define the $connection_upgrade variable used below
28+ map $http_upgrade $connection_upgrade {
29+ default upgrade;
30+ '' close;
31+ }
32+
33+ # ───────── 1) Redirect herokuapp host -> canonical domain ─────────
34+ server {
35+ listen $PORT ;
36+ listen [::]:$PORT ;
37+ server_name wetlands-gap-map -staging-b3fdd14996a5.herokuapp.com www.wetlands-gap-map -staging-b3fdd14996a5.herokuapp.com;
38+
39+ return 301 https://gaps-staging.wetlands.org$request_uri ;
40+ }
41+
42+ # ───────── 2) App server for gaps-staging.wetlands.org ─────────
2543 server {
2644 listen $PORT ;
27- listen [::]:$PORT ;
45+ listen [::]:$PORT ;
46+ server_name gaps-staging.wetlands.org www.gaps-staging.wetlands.org;
2847
2948 client_max_body_size 50m ;
3049
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