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.
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`
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

View File

@ -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.

View File

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

View File

@ -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