From cacdcba2d2f52b556d10c1c4d68b7c04fbf93c43 Mon Sep 17 00:00:00 2001 From: stianst Date: Wed, 22 Feb 2023 08:02:57 +0100 Subject: [PATCH] More --- kc-production/nginx-proxy/Dockerfile | 4 +++- kc-production/nginx-proxy/default.conf | 1 + kc-production/nginx-proxy/hostname-basic.conf | 13 +++++++++++++ kc-production/nginx-proxy/hostname-xheaders.conf | 15 +++++++++++++++ kc-production/nginx-proxy/start.sh | 11 +++++++++-- 5 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 kc-production/nginx-proxy/hostname-basic.conf create mode 100644 kc-production/nginx-proxy/hostname-xheaders.conf diff --git a/kc-production/nginx-proxy/Dockerfile b/kc-production/nginx-proxy/Dockerfile index 0b21caa..4e3e39b 100644 --- a/kc-production/nginx-proxy/Dockerfile +++ b/kc-production/nginx-proxy/Dockerfile @@ -1,2 +1,4 @@ FROM docker.io/nginx -COPY default.conf /etc/nginx/conf.d/default.conf + +ARG conf_file +COPY $conf_file /etc/nginx/conf.d/default.conf diff --git a/kc-production/nginx-proxy/default.conf b/kc-production/nginx-proxy/default.conf index d0fcbea..2bbfc18 100644 --- a/kc-production/nginx-proxy/default.conf +++ b/kc-production/nginx-proxy/default.conf @@ -1,5 +1,6 @@ upstream localhost { server localhost:8080; + server localhost:8081; } server { diff --git a/kc-production/nginx-proxy/hostname-basic.conf b/kc-production/nginx-proxy/hostname-basic.conf new file mode 100644 index 0000000..8bcb711 --- /dev/null +++ b/kc-production/nginx-proxy/hostname-basic.conf @@ -0,0 +1,13 @@ +upstream mycluster { + server localhost:8080; +} + +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + + location / { + proxy_pass http://mycluster/; + } +} diff --git a/kc-production/nginx-proxy/hostname-xheaders.conf b/kc-production/nginx-proxy/hostname-xheaders.conf new file mode 100644 index 0000000..eb76b32 --- /dev/null +++ b/kc-production/nginx-proxy/hostname-xheaders.conf @@ -0,0 +1,15 @@ +upstream mycluster { + server localhost:8080; +} + +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + + location / { + proxy_pass http://mycluster/; + proxy_set_header X-Forwarded-For "localhost"; + proxy_set_header X-Forwarded-Proto "http"; + } +} diff --git a/kc-production/nginx-proxy/start.sh b/kc-production/nginx-proxy/start.sh index 88ac087..9f38130 100755 --- a/kc-production/nginx-proxy/start.sh +++ b/kc-production/nginx-proxy/start.sh @@ -2,5 +2,12 @@ cd $(readlink -f $0 | xargs dirname) -sudo podman build -t example-proxy . -sudo podman run --network=host example-proxy \ No newline at end of file +CONF_FILE=$1 + +if [ "$1" == "" ] || [ ! -f "$1" ]; then + echo "usage: start.sh " + exit 1 +fi + +sudo podman build --build-arg conf_file=$CONF_FILE -t example-proxy . +sudo podman run --network=host example-proxy