diff options
| author | Patrick Spek <p.spek@tyil.nl> | 2024-07-17 23:39:24 +0200 |
|---|---|---|
| committer | Patrick Spek <p.spek@tyil.nl> | 2024-07-17 23:39:24 +0200 |
| commit | d217a7d1bd6c461a7a93d7c3c36d86383c161192 (patch) | |
| tree | d115e91fbbf3c287871755fdb47c775526b06b97 | |
| download | proxy-http-d217a7d1bd6c461a7a93d7c3c36d86383c161192.tar.gz proxy-http-d217a7d1bd6c461a7a93d7c3c36d86383c161192.tar.bz2 | |
Initial commit
| -rw-r--r-- | Dockerfile | 8 | ||||
| -rw-r--r-- | entrypoint.sh | 11 | ||||
| -rw-r--r-- | nginx.conf | 27 |
3 files changed, 46 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b1eaf3f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine + +RUN apk add --no-cache nginx + +COPY entrypoint.sh /entrypoint.sh +COPY nginx.conf /etc/nginx/nginx.conf.template + +CMD [ "/bin/sh", "/entrypoint.sh" ] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..2c4eea7 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +sed \ + -e "s/%%PROXY_LISTEN_PORT%%/${PROXY_LISTEN_PORT:-80}/" \ + -e "s/%%PROXY_HOSTNAME%%/${PROXY_HOSTNAME:-$(hostname -f)}/" \ + -e "s/%%PROXY_DESTINATION_HOST%%/${PROXY_DESTINATION_HOST:?}/" \ + -e "s/%%PROXY_DESTINATION_PORT%%/${PROXY_DESTINATION_PORT:-80}/" \ + -e "s/%%PROXY_DESTINATION_PROTOCOL%%/${PROXY_DESTINATION_PROTOCOL:-http}/" \ + < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf + +exec nginx -g "daemon off;" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f1281bf --- /dev/null +++ b/nginx.conf @@ -0,0 +1,27 @@ +worker_processes auto; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + + server { + listen %%PROXY_LISTEN_PORT%% default_server; + listen [::]:%%PROXY_LISTEN_PORT%% default_server; + + server_name "%%PROXY_HOSTNAME%%"; + + set $upstream_url "%%PROXY_DESTINATION_PROTOCOL%%://%%PROXY_DESTINATION_HOST%%:%%PROXY_DESTINATION_PORT%%"; + + location / { + proxy_set_header Host $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_pass $upstream_url; + } + } +} |
