custom root folder and little fixes

This commit is contained in:
bunkerity 2020-08-22 00:12:36 +02:00
parent b14b09ad5d
commit bf605ce59d
4 changed files with 23 additions and 8 deletions

View File

@ -116,6 +116,11 @@ Default value : *yes*
If set to yes, nginx will serve files from /www directory within the container. 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. A use case to not serving files is when you setup bunkerized-nginx as a reverse proxy via a custom configuration.
`ROOT_FOLDER`
Values : *\<any valid path to web files\>
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` `MAX_CLIENT_SIZE`
Values : *0* | *Xm* Values : *0* | *Xm*
Default value : *10m* Default value : *10m*
@ -385,17 +390,22 @@ Here is a Dockerfile example :
``` ```
FROM bunkerity/bunkerized-nginx FROM bunkerity/bunkerized-nginx
# Copy your web files inside the /www folder # Copy your web files to a folder
COPY ./some-files/ /www/ COPY ./web-files/ /opt/web-files
# Optional : add your own script to be executed on startup # Optional : add your own script to be executed on startup
COPY ./my-entrypoint.sh /opt/entrypoint.d/ COPY ./my-entrypoint.sh /entrypoint.d/my-entrypoint.sh
RUN chmod +x /opt/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 MAX_CLIENT_SIZE 100m
ENV PHP_UPLOAD_MAX_FILESIZE 100M ENV PHP_UPLOAD_MAX_FILESIZE 100M
ENV WRITE_ACCESS yes ENV WRITE_ACCESS yes
ENV ADDITIONAL_MODULES php7-mysqli php7-json php7-session
``` ```
# Include custom configurations # Include custom configurations

View File

@ -747,7 +747,7 @@ include_path = ".:/usr/share/php7"
; see documentation for security issues. The alternate is to use the ; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below ; cgi.force_redirect configuration below
; http://php.net/doc-root ; http://php.net/doc-root
doc_root = /www/ doc_root = %ROOT_FOLDER%
; The directory under which PHP opens the script using /~username used only ; The directory under which PHP opens the script using /~username used only
; if nonempty. ; if nonempty.

View File

@ -1,3 +1,3 @@
root /www; root %ROOT_FOLDER%;
index index.html index.php; index index.html index.php;
try_files $uri $uri/ =404; try_files $uri $uri/ =404;

View File

@ -3,7 +3,9 @@
echo "[*] Starting bunkerized-nginx ..." echo "[*] Starting bunkerized-nginx ..."
# execute custom scripts if it's a customized image # 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 # trap SIGTERM and SIGINT
function trap_exit() { function trap_exit() {
@ -101,6 +103,7 @@ AUTH_BASIC_LOCATION="${AUTH_BASIC_LOCATION-/}"
AUTH_BASIC_USER="${AUTH_BASIC_USER-changeme}" AUTH_BASIC_USER="${AUTH_BASIC_USER-changeme}"
AUTH_BASIC_PASSWORD="${AUTH_BASIC_PASSWORD-changeme}" AUTH_BASIC_PASSWORD="${AUTH_BASIC_PASSWORD-changeme}"
USE_HTTPS_CUSTOM="${USE_HTTPS_CUSTOM-no}" USE_HTTPS_CUSTOM="${USE_HTTPS_CUSTOM-no}"
ROOT_FOLDER="${ROOT_FOLDER-/www}"
# install additional modules if needed # install additional modules if needed
if [ "$ADDITIONAL_MODULES" != "" ] ; then 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_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_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" "%PHP_POST_MAX_SIZE%" "$PHP_POST_MAX_SIZE"
replace_in_file "/etc/php7/php.ini" "%ROOT_FOLDER%" "$ROOT_FOLDER"
else else
replace_in_file "/etc/nginx/server.conf" "%USE_PHP%" "" replace_in_file "/etc/nginx/server.conf" "%USE_PHP%" ""
fi fi
@ -332,6 +336,7 @@ else
fi fi
if [ "$SERVE_FILES" = "yes" ] ; then 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/server.conf" "%SERVE_FILES%" "include /etc/nginx/serve-files.conf;"
replace_in_file "/etc/nginx/serve-files.conf" "%ROOT_FOLDER%" "$ROOT_FOLDER"
else else
replace_in_file "/etc/nginx/server.conf" "%SERVE_FILES%" "" replace_in_file "/etc/nginx/server.conf" "%SERVE_FILES%" ""
fi fi