summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-11-03 20:14:55 +0300
committerAndrew Dolgov <[email protected]>2023-11-03 20:14:55 +0300
commit9bbd7825ac162897f56aa6b6ec8a79b369db41ba (patch)
tree362b80164febf49afe710b316a5a987893688d5c
parentedd60388639225e6f57e2276c33a7f7df968a1bf (diff)
make FPM upstream / web root configurable with envsubst like tt-rss
-rw-r--r--.docker/web-nginx/Dockerfile22
-rw-r--r--.docker/web-nginx/nginx.conf8
2 files changed, 25 insertions, 5 deletions
diff --git a/.docker/web-nginx/Dockerfile b/.docker/web-nginx/Dockerfile
index 41d8e3f..21b8645 100644
--- a/.docker/web-nginx/Dockerfile
+++ b/.docker/web-nginx/Dockerfile
@@ -1,3 +1,23 @@
FROM registry.fakecake.org/docker.io/nginx:alpine
-COPY .docker/web-nginx/nginx.conf /etc/nginx/nginx.conf
+COPY .docker/web-nginx/nginx.conf /etc/nginx/templates/nginx.conf.template
+
+# By default, nginx will send the php requests to "app" server, but this server
+# name can be overridden at runtime by passing an APP_UPSTREAM env var
+ENV APP_UPSTREAM=${APP_UPSTREAM:-app}
+
+# Webroot (defaults to /var/www/html)
+ENV APP_WEB_ROOT=${APP_WEB_ROOT:-/var/www/html}
+
+# Base location for epube (defaults to /books)
+ENV APP_BASE=${APP_BASE:-/books}
+
+# In order to make epube appear on website root without /books/ set above as follows in .env:
+# APP_WEB_ROOT=/var/www/html/books
+# APP_BASE=
+
+# It's necessary to set the following NGINX_ENVSUBST_OUTPUT_DIR env var to tell
+# nginx to replace the env vars of /etc/nginx/templates/nginx.conf.template
+# and put the result in /etc/nginx/nginx.conf (instead of /etc/nginx/conf.d/nginx.conf)
+# See https://github.com/docker-library/docs/tree/master/nginx#using-environment-variables-in-nginx-configuration-new-in-119
+ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx
diff --git a/.docker/web-nginx/nginx.conf b/.docker/web-nginx/nginx.conf
index 12d526a..ee297fd 100644
--- a/.docker/web-nginx/nginx.conf
+++ b/.docker/web-nginx/nginx.conf
@@ -18,19 +18,19 @@ http {
index index.php;
upstream app {
- server app:9000;
+ server ${APP_UPSTREAM}:9000;
}
server {
listen 80;
listen [::]:80;
- root /var/www/html;
+ root ${APP_WEB_ROOT};
- location /books/db {
+ location ${APP_BASE}/db {
internal;
}
- location /books/sessions {
+ location ${APP_BASE}/sessions {
internal;
}