Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 8b33beb

Browse files
authored
Merge pull request #3 from tomsolem/add-host-header
Add new variable to enable or disable setting the host header
2 parents 7610404 + 347c9aa commit 8b33beb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ environment variables is used in this image:
3333
* `PROXY_PORT`: Port of the service to proxy
3434
* `PROXY_PROTOCOL`: Protofol to the service to proxy (`http` or `https`)
3535

36+
* `ADD_HOST_HEADER`: pass the proxy host header downstream (`true` or `false`)
37+
3638
```
3739
docker run \
3840
-e OID_DISCOVERY=https://my-auth-server/auth \

nginx/conf/nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ env OIDC_RENEW_ACCESS_TOKEN_ON_EXPIERY;
1919
env PROXY_HOST;
2020
env PROXY_PORT;
2121
env PROXY_PROTOCOL;
22+
env ADD_HOST_HEADER;
2223

2324
events {
2425
worker_connections 1024;

nginx/conf/sites/proxy.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ server {
1111
set_by_lua $proxy_host 'return os.getenv("PROXY_HOST")';
1212
set_by_lua $proxy_port 'return os.getenv("PROXY_PORT")';
1313
set_by_lua $proxy_protocol 'return os.getenv("PROXY_PROTOCOL")';
14+
set_by_lua $add_host_header 'return os.getenv("ADD_HOST_HEADER")';
1415

1516
error_log /dev/stdout notice;
1617

@@ -25,7 +26,13 @@ server {
2526
location / {
2627
access_by_lua_file lua/auth.lua;
2728

28-
proxy_set_header Host $http_host;
29+
set $reverse_proxy_host $proxy_host;
30+
31+
if ($add_host_header = "true") {
32+
set $reverse_proxy_host $http_host;
33+
}
34+
35+
proxy_set_header Host $reverse_proxy_host;
2936
proxy_pass $proxy_protocol://$proxy_host:$proxy_port;
3037
}
3138

0 commit comments

Comments
 (0)