From d217a7d1bd6c461a7a93d7c3c36d86383c161192 Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Wed, 17 Jul 2024 23:39:24 +0200
Subject: Initial commit
---
Dockerfile | 8 ++++++++
entrypoint.sh | 11 +++++++++++
nginx.conf | 27 +++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
create mode 100644 Dockerfile
create mode 100644 entrypoint.sh
create mode 100644 nginx.conf
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;
+ }
+ }
+}
--
cgit v1.2.3