diff --git a/README.md b/README.md index 740a213..2012bd8 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,11 @@ Default value : *yes* If set to yes, nginx will serve files from /www directory within the container. A use case to not serving files is when you setup bunkerized-nginx as a reverse proxy via a custom configuration. +`ROOT_FOLDER` +Values : *\ +Default value : */www* +The default folder where nginx will search for web files. Don't change it unless you want to make your own image (TODO). + `MAX_CLIENT_SIZE` Values : *0* | *Xm* Default value : *10m* @@ -385,17 +390,22 @@ Here is a Dockerfile example : ``` FROM bunkerity/bunkerized-nginx -# Copy your web files inside the /www folder -COPY ./some-files/ /www/ +# Copy your web files to a folder +COPY ./web-files/ /opt/web-files # Optional : add your own script to be executed on startup -COPY ./my-entrypoint.sh /opt/entrypoint.d/ -RUN chmod +x /opt/entrypoint.d/my-entrypoint.sh +COPY ./my-entrypoint.sh /entrypoint.d/my-entrypoint.sh +RUN chmod +x /entrypoint.d/my-entrypoint.sh -# Optional : define some environment variables +# Mandatory variables to make things working +ENV ROOT_FOLDER /opt/web-files +ENV PHP_OPEN_BASEDIR /opt/web-files/:/tmp/ + +# Optional variables ENV MAX_CLIENT_SIZE 100m ENV PHP_UPLOAD_MAX_FILESIZE 100M ENV WRITE_ACCESS yes +ENV ADDITIONAL_MODULES php7-mysqli php7-json php7-session ``` # Include custom configurations diff --git a/confs/php.ini b/confs/php.ini index 296e6de..f6ff499 100644 --- a/confs/php.ini +++ b/confs/php.ini @@ -747,7 +747,7 @@ include_path = ".:/usr/share/php7" ; see documentation for security issues. The alternate is to use the ; cgi.force_redirect configuration below ; http://php.net/doc-root -doc_root = /www/ +doc_root = %ROOT_FOLDER% ; The directory under which PHP opens the script using /~username used only ; if nonempty. diff --git a/confs/serve-files.conf b/confs/serve-files.conf index 01d723a..d920e93 100644 --- a/confs/serve-files.conf +++ b/confs/serve-files.conf @@ -1,3 +1,3 @@ -root /www; +root %ROOT_FOLDER%; index index.html index.php; try_files $uri $uri/ =404; diff --git a/entrypoint.sh b/entrypoint.sh index 71c95ea..cf4b363 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,7 +3,9 @@ echo "[*] Starting bunkerized-nginx ..." # execute custom scripts if it's a customized image -run-parts /opt/entrypoint.d +for file in /entrypoint.d/* ; do + [ -f "$file" ] && [ -x "$file" ] && "$file" +done # trap SIGTERM and SIGINT function trap_exit() { @@ -101,6 +103,7 @@ AUTH_BASIC_LOCATION="${AUTH_BASIC_LOCATION-/}" AUTH_BASIC_USER="${AUTH_BASIC_USER-changeme}" AUTH_BASIC_PASSWORD="${AUTH_BASIC_PASSWORD-changeme}" USE_HTTPS_CUSTOM="${USE_HTTPS_CUSTOM-no}" +ROOT_FOLDER="${ROOT_FOLDER-/www}" # install additional modules if needed if [ "$ADDITIONAL_MODULES" != "" ] ; then @@ -149,6 +152,7 @@ if [ "$USE_PHP" = "yes" ] ; then replace_in_file "/etc/php7/php.ini" "%PHP_UPLOAD_MAX_FILESIZE%" "$PHP_UPLOAD_MAX_FILESIZE" replace_in_file "/etc/php7/php.ini" "%PHP_DISABLE_FUNCTIONS%" "$PHP_DISABLE_FUNCTIONS" replace_in_file "/etc/php7/php.ini" "%PHP_POST_MAX_SIZE%" "$PHP_POST_MAX_SIZE" + replace_in_file "/etc/php7/php.ini" "%ROOT_FOLDER%" "$ROOT_FOLDER" else replace_in_file "/etc/nginx/server.conf" "%USE_PHP%" "" fi @@ -332,6 +336,7 @@ else fi if [ "$SERVE_FILES" = "yes" ] ; then replace_in_file "/etc/nginx/server.conf" "%SERVE_FILES%" "include /etc/nginx/serve-files.conf;" + replace_in_file "/etc/nginx/serve-files.conf" "%ROOT_FOLDER%" "$ROOT_FOLDER" else replace_in_file "/etc/nginx/server.conf" "%SERVE_FILES%" "" fi