proxy caching support
This commit is contained in:
parent
60fbbc1013
commit
8f7cb5318e
|
@ -90,6 +90,9 @@ http {
|
|||
# list of blocked user agents
|
||||
%BLOCK_USER_AGENT%
|
||||
|
||||
# zone for proxy_cache
|
||||
%PROXY_CACHE_PATH%
|
||||
|
||||
# custom http confs
|
||||
include /http-confs/*.conf;
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
proxy_cache proxycache;
|
||||
proxy_cache_methods %PROXY_CACHE_METHODS%;
|
||||
proxy_cache_min_uses %PROXY_CACHE_MIN_USES%;
|
||||
proxy_cache_key %PROXY_CACHE_KEY%;
|
||||
proxy_no_cache %PROXY_NO_CACHE%;
|
||||
proxy_cache_bypass %PROXY_CACHE_BYPASS%;
|
||||
%PROXY_CACHE_VALID%
|
|
@ -37,4 +37,5 @@ server {
|
|||
client_max_body_size %MAX_CLIENT_SIZE%;
|
||||
server_tokens %SERVER_TOKENS%;
|
||||
%USE_OPEN_FILE_CACHE%
|
||||
%USE_PROXY_CACHE%
|
||||
}
|
||||
|
|
|
@ -13,6 +13,15 @@ OPEN_FILE_CACHE="${OPEN_FILE_CACHE-max=1000 inactive=20s}"
|
|||
OPEN_FILE_CACHE_ERRORS="${OPEN_FILE_CACHE_ERRORS-on}"
|
||||
OPEN_FILE_CACHE_MIN_USES="${OPEN_FILE_CACHE_MIN_USES-2}"
|
||||
OPEN_FILE_CACHE_VALID="${OPEN_FILE_CACHE_VALID-30s}"
|
||||
USE_PROXY_CACHE="${USE_PROXY_CACHE-no}"
|
||||
PROXY_CACHE_PATH_ZONE_SIZE="${PROXY_CACHE_PATH_ZONE_SIZE-10m}"
|
||||
PROXY_CACHE_PATH_PARAMS="${PROXY_CACHE_PATH_PARAMS-max_size=100m}"
|
||||
PROXY_CACHE_METHODS="${PROXY_CACHE_METHODS-GET HEAD}"
|
||||
PROXY_CACHE_MIN_USES="${PROXY_CACHE_MIN_USES-2}"
|
||||
PROXY_CACHE_KEY="${PROXY_CACHE_KEY-\$scheme\$host\$request_uri}"
|
||||
PROXY_CACHE_VALID="${PROXY_CACHE_VALID-200=10m 301=10m 301=1h any=1m}"
|
||||
PROXY_NO_CACHE="${PROXY_NO_CACHE-\$http_pragma \$http_authorization}"
|
||||
PROXY_CACHE_BYPASS="${PROXY_CACHE_BYPASS-\$http_pragma \$http_authorization}"
|
||||
USE_GZIP="${USE_GZIP-no}"
|
||||
GZIP_COMP_LEVEL="${GZIP_COMP_LEVEL-5}"
|
||||
GZIP_MIN_LENGTH="${GZIP_MIN_LENGTH-1000}"
|
||||
|
|
|
@ -31,6 +31,13 @@ else
|
|||
replace_in_file "/etc/nginx/nginx.conf" "%INCLUDE_SERVER%" "include /etc/nginx/server.conf;"
|
||||
fi
|
||||
|
||||
# proxy_cache zone
|
||||
if [ "$USE_PROXY_CACHE" = "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%" ""
|
||||
fi
|
||||
|
||||
# let's encrypt setup
|
||||
if [ "$AUTO_LETS_ENCRYPT" = "yes" ] ; then
|
||||
FIRST_SERVER_NAME=$(echo "$SERVER_NAME" | cut -d " " -f 1)
|
||||
|
|
|
@ -31,7 +31,7 @@ cp /opt/confs/site/* "$NGINX_PREFIX"
|
|||
# replace paths
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%MAIN_LUA%" "include ${NGINX_PREFIX}main-lua.conf;"
|
||||
if [ "$MULTISITE" = "yes" ] ; then
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%SERVER_CONF%" "include /server-confs/${1}/*.conf;"
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%SERVER_CONF%" "include /server-confs/*.conf;\ninclude /server-confs/${1}/*.conf;"
|
||||
else
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%SERVER_CONF%" "include /server-confs/*.conf;"
|
||||
fi
|
||||
|
@ -42,6 +42,25 @@ 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"
|
||||
|
||||
# proxy caching
|
||||
if [ "$USE_PROXY_CACHE" = "yes" ] ; then
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%USE_PROXY_CACHE%" "include ${NGINX_PREFIX}proxy-cache.conf;"
|
||||
replace_in_file "${NGINX_PREFIX}proxy-cache.conf" "%PROXY_CACHE_METHODS%" "$PROXY_CACHE_METHODS"
|
||||
replace_in_file "${NGINX_PREFIX}proxy-cache.conf" "%PROXY_CACHE_MIN_USES%" "$PROXY_CACHE_MIN_USES"
|
||||
replace_in_file "${NGINX_PREFIX}proxy-cache.conf" "%PROXY_CACHE_KEY%" "$PROXY_CACHE_KEY"
|
||||
replace_in_file "${NGINX_PREFIX}proxy-cache.conf" "%PROXY_NO_CACHE%" "$PROXY_NO_CACHE"
|
||||
replace_in_file "${NGINX_PREFIX}proxy-cache.conf" "%PROXY_CACHE_BYPASS%" "$PROXY_CACHE_BYPASS"
|
||||
valids=""
|
||||
for valid in $PROXY_CACHE_VALID ; do
|
||||
code="$(echo $valid | cut -d '=' -f 1)"
|
||||
timing="$(echo $valid | cut -d '=' -f 2)"
|
||||
valids="${valids}\nproxy_cache_valid ${code} ${timing};"
|
||||
done
|
||||
replace_in_file "${NGINX_PREFIX}proxy-cache.conf" "%PROXY_CACHE_VALID%" "$valids"
|
||||
else
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%USE_PROXY_CACHE%" ""
|
||||
fi
|
||||
|
||||
# file metadata caching
|
||||
if [ "$USE_OPEN_FILE_CACHE" = "yes" ] ; then
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%USE_OPEN_FILE_CACHE%" "include ${NGINX_PREFIX}open-file-cache.conf;"
|
||||
|
@ -50,7 +69,7 @@ if [ "$USE_OPEN_FILE_CACHE" = "yes" ] ; then
|
|||
replace_in_file "${NGINX_PREFIX}open-file-cache.conf" "%OPEN_FILE_CACHE_MIN_USES%" "$OPEN_FILE_CACHE_MIN_USES"
|
||||
replace_in_file "${NGINX_PREFIX}open-file-cache.conf" "%OPEN_FILE_CACHE_VALID%" "$OPEN_FILE_CACHE_VALID"
|
||||
else
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%OPEN_FILE_CACHE%" ""
|
||||
replace_in_file "${NGINX_PREFIX}server.conf" "%USE_OPEN_FILE_CACHE%" ""
|
||||
fi
|
||||
|
||||
# client caching
|
||||
|
|
Loading…
Reference in New Issue