Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: forward proto from reverse proxy #1524

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,11 @@ http {

include /etc/nginx/conf.d/features.conf;

# use the scheme from the X-Forwarded-Proto header if present or default to $scheme
map $http_x_forwarded_proto $thescheme {
default $http_x_forwarded_proto;
'' $scheme;
}

include /etc/nginx/conf.d/multi-channel.conf;
}
6 changes: 3 additions & 3 deletions nginx/templates/multi-channel.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto $thescheme;

add_header X-Cache-Status $upstream_cache_status;
proxy_ignore_headers Cache-Control;
Expand Down Expand Up @@ -135,7 +135,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto $thescheme;

proxy_no_cache true;
proxy_cache_bypass true;
Expand All @@ -155,7 +155,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto $thescheme;

proxy_ignore_headers Cache-Control;
proxy_cache_valid 200 302 {{ getenv "CACHE_DURATION_NGINX_OK" }};
Expand Down
4 changes: 4 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ export function app() {

console.log('ICM_BASE_URL is', ICM_BASE_URL);

// running behind nginx - make sure to use all x-forwarded headers correctly
// see https://expressjs.com/en/guide/behind-proxies.html
server.set('trust proxy', true);

return server;
}

Expand Down
Loading