reverse: allow to disable hsts and headers

This commit is contained in:
root 2017-09-18 18:37:21 +02:00
parent 89cb674a37
commit 43b9cb8c41
4 changed files with 18 additions and 4 deletions

View File

@ -0,0 +1 @@
add_header Strict-Transport-Security "max-age=31536000";

View File

@ -6,5 +6,3 @@ ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 15m;
ssl_session_tickets off;
add_header Strict-Transport-Security "max-age=31536000";

View File

@ -17,6 +17,7 @@ server {
ssl_trusted_certificate /nginx/ssl/certificates/<frontend_domain>.chain.pem;
include /nginx/conf.d/ssl.conf;
include /nginx/conf.d/headers.conf;
include /nginx/conf.d/hsts.conf;
include /nginx/path.d/<frontend_domain>/*.conf;

View File

@ -36,6 +36,12 @@ f_gen_sites_enabled() {
template_sites=/nginx/sites-enabled/template
fi
sed -e 's|<frontend_domain>|'${FRONTEND_DOMAIN}'|' ${template_sites} > /nginx/sites-enabled/${FRONTEND_DOMAIN}.conf
if [ "${FRONTEND_HSTS}" == "false" ]; then
sed -i -e "s|include /nginx/conf.d/hsts.conf|#include /nginx/conf.d/hsts.conf|g" /nginx/sites-enabled/${FRONTEND_DOMAIN}.conf
fi
if [ "${FRONTEND_HEADERS}" == "false" ]; then
sed -i -e "s|include /nginx/conf.d/headers.conf|#include /nginx/conf.d/headers.conf|g" /nginx/sites-enabled/${FRONTEND_DOMAIN}.conf
fi
}
f_gen_location() {
@ -101,6 +107,8 @@ f_make_conf() {
FRONTEND_PATH="/"
FRONTEND_SSL=false
FRONTEND_AUTH=""
FRONTEND_HSTS=true
FRONTEND_HEADERS=true
container_name=$1
IFS=$'\n'
@ -123,15 +131,21 @@ f_make_conf() {
"reverse.frontend.domain_max_body_size")
FRONTEND_MAX_BODY_SIZE="$(echo ${label} | awk '{print $2}')"
;;
"reverse.frontend.headers")
FRONTEND_HEADERS="$(echo ${label} | awk '{print $2}')"
;;
"reverse.frontend.ssl")
FRONTEND_SSL="$(echo ${label} | awk '{print $2}')"
;;
"reverse.frontend.hsts")
FRONTEND_HSTS="$(echo ${label} | awk '{print $2}')"
;;
"reverse.backend.port")
BACKEND_PORT="$(echo ${label} | awk '{print $2}')"
;;
esac
done
f_log INF "Generate files for ${FRONTEND_DOMAIN}, with path=${FRONTEND_PATH}, auth=${FRONTEND_AUTH}, ssl_type=${FRONTEND_SSLTYPE}, ssl=${FRONTEND_SSL} and port=${BACKEND_PORT}"
f_log INF "Generate files for ${FRONTEND_DOMAIN}, with path=${FRONTEND_PATH}, auth=${FRONTEND_AUTH}, hsts=${FRONTEND_HEADERS}, ssl_type=${FRONTEND_SSLTYPE}, ssl=${FRONTEND_SSL}, hsts=${FRONTEND_HSTS} and port=${BACKEND_PORT}"
f_gen_location ${container_name}
f_gen_sites_enabled
f_gen_certs ${container_name}