reverse proxy support via env vars

This commit is contained in:
bunkerity 2020-11-14 17:30:38 +01:00
parent 8f7cb5318e
commit 0f18e9c552
No known key found for this signature in database
GPG Key ID: 654FFF51CEF7CC47
5 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,7 @@
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
location %REVERSE_PROXY_URL% {
proxy_pass %REVERSE_PROXY_LOCATION%;
}

View File

@ -38,4 +38,5 @@ server {
server_tokens %SERVER_TOKENS%;
%USE_OPEN_FILE_CACHE%
%USE_PROXY_CACHE%
%USE_REVERSE_PROXY%
}

View File

@ -31,6 +31,7 @@ BROTLI_COMP_LEVEL="${BROTLI_COMP_LEVEL-6}"
BROTLI_MIN_LENGTH="${BROTLI_MIN_LENGTH-1000}"
BROTLI_TYPES="${BROTLI_TYPES-application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml}"
REMOTE_PHP_PATH="${REMOTE_PHP_PATH-/app}"
USE_REVERSE_PROXY="${USE_REVERSE_PROXY-no}"
HEADER_SERVER="${HEADER_SERVER-no}"
X_FRAME_OPTIONS="${X_FRAME_OPTIONS-DENY}"
X_XSS_PROTECTION="${X_XSS_PROTECTION-1; mode=block}"

View File

@ -32,7 +32,7 @@ else
fi
# proxy_cache zone
if [ "$USE_PROXY_CACHE" = "yes" ] ; then
if [ "$(has_value USE_PROXY_CACHE yes)" = "yes" ] ; then
replace_in_file "/etc/nginx/nginx.conf" "%PROXY_CACHE_PATH%" "proxy_cache_path /tmp/proxy_cache keys_zone=proxycache:${PROXY_CACHE_PATH_ZONE_SIZE} ${PROXY_CACHE_PATH_PARAMS};"
else
replace_in_file "/etc/nginx/nginx.conf" "%PROXY_CACHE_PATH%" ""

View File

@ -42,6 +42,16 @@ replace_in_file "{NGINX_PREFIX}server.conf" "%MAX_CLIENT_SIZE%" "$MAX_CLIENT_SIZ
# server tokens
replace_in_file "{NGINX_PREFIX}server.conf" "%SERVER_TOKENS%" "$SERVER_TOKENS"
# reverse proxy
if [ "$USE_REVERSE_PROXY" = "yes" ] ; then
replace_in_file "${NGINX_PREFIX}server.conf" "%USE_REVERSE_PROXY%" "include ${NGINX_PREFIX}reverse-proxy.conf"
replace_in_file "${NGINX_PREFIX}reverse-proxy.conf" "%REVERSE_PROXY_URL%" "$REVERSE_PROXY_URL"
replace_in_file "${NGINX_PREFIX}reverse-proxy.conf" "%REVERSE_PROXY_HOST%" "$REVERSE_PROXY_HOST"
else
replace_in_file "${NGINX_PREFIX}server.conf" "%USE_REVERSE_PROXY%" ""
fi
# proxy caching
if [ "$USE_PROXY_CACHE" = "yes" ] ; then
replace_in_file "${NGINX_PREFIX}server.conf" "%USE_PROXY_CACHE%" "include ${NGINX_PREFIX}proxy-cache.conf;"