Skip to content

Commit 6be5bd3

Browse files
Merge pull request #121 from DigitalPatterns/master
add option to disable default security headers
2 parents fce21c9 + 7bbe3bc commit 6be5bd3

File tree

4 files changed

+32
-22
lines changed

4 files changed

+32
-22
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ADD ./go.sh /
2626
ADD ./enable_location.sh /
2727
ADD ./location_template.conf /
2828
ADD ./logging.conf /usr/local/openresty/nginx/conf/
29+
ADD ./security_defaults.conf /usr/local/openresty/nginx/conf/
2930
ADD ./html/ /usr/local/openresty/nginx/html/
3031
ADD ./readyness.sh /
3132
ADD ./helper.sh /

go.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ cat > ${NGIX_LISTEN_CONF} <<-EOF-LISTEN
3535
listen localhost:${INTERNAL_LISTEN_PORT} ssl;
3636
EOF-LISTEN
3737

38+
if [ "${CUSTOM_SECURITY_DEFAULTS}" == "TRUE" ]; then
39+
msg "Disabling inbuilt security headers add per location"
40+
> /usr/local/openresty/nginx/conf/security_defaults.conf
41+
fi
42+
3843
if [ "${LOAD_BALANCER_CIDR}" != "" ]; then
3944
msg "Using proxy_protocol from '$LOAD_BALANCER_CIDR' (real client ip is forwarded correctly by loadbalancer)..."
4045
export REMOTE_IP_VAR="proxy_protocol_addr"
@@ -72,10 +77,12 @@ if [ -z ${DISABLE_SYSDIG_METRICS+x} ]; then
7277
EOF-SYSDIG-SERVER
7378
fi
7479

75-
IFS=',' read -a LOCATIONS_ARRAY <<< "$LOCATIONS_CSV"
76-
for i in "${!LOCATIONS_ARRAY[@]}"; do
77-
/enable_location.sh $((${i} + 1)) ${LOCATIONS_ARRAY[$i]}
78-
done
80+
if [ "${CUSTOM_PROXY_CONFIG}" != "TRUE" ]; then
81+
IFS=',' read -a LOCATIONS_ARRAY <<< "$LOCATIONS_CSV"
82+
for i in "${!LOCATIONS_ARRAY[@]}"; do
83+
/enable_location.sh $((${i} + 1)) ${LOCATIONS_ARRAY[$i]}
84+
done
85+
fi
7986

8087
if [ "${NAME_RESOLVER}" == "" ]; then
8188
if [ "${DNSMASK}" == "TRUE" ]; then

nginx.conf

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,7 @@ http {
8181
include /usr/local/openresty/nginx/conf/upload_size*.conf;
8282
include /usr/local/openresty/nginx/conf/nginx_http_extras*.conf;
8383

84-
# config to not allow the browser to render the page inside an frame or iframe
85-
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
86-
add_header X-Frame-Options SAMEORIGIN;
87-
88-
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
89-
# to disable content-type sniffing on some browsers.
90-
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
91-
add_header X-Content-Type-Options nosniff;
92-
93-
# This header enables the Cross-site scripting (XSS) filter built into most recent web browsers.
94-
# It's usually enabled by default anyway, so the role of this header is to re-enable the filter for
95-
# this particular website if it was disabled by the user.
96-
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
97-
add_header X-XSS-Protection "1; mode=block";
98-
99-
# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
100-
# to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
101-
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
84+
include /usr/local/openresty/nginx/conf/security_defaults.conf;
10285

10386
# Accept underscores in headers as NAXSI does this
10487
underscores_in_headers on;

security_defaults.conf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
# config to not allow the browser to render the page inside an frame or iframe
3+
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
4+
add_header X-Frame-Options SAMEORIGIN;
5+
6+
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
7+
# to disable content-type sniffing on some browsers.
8+
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
9+
add_header X-Content-Type-Options nosniff;
10+
11+
# This header enables the Cross-site scripting (XSS) filter built into most recent web browsers.
12+
# It's usually enabled by default anyway, so the role of this header is to re-enable the filter for
13+
# this particular website if it was disabled by the user.
14+
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
15+
add_header X-XSS-Protection "1; mode=block";
16+
17+
# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
18+
# to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
19+
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

0 commit comments

Comments
 (0)