From baacf6b924fc62305c78e8b7dfb6ed8167bb2e4e Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 28 Jul 2021 17:25:18 +0200 Subject: [PATCH] Undefine X-Frame-Options before setting it. --- defaults/main.yml | 4 +++- templates/nginx-virthost.j2 | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index e8f0d70..bc499cb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -89,7 +89,8 @@ nginx_cors_allowed_methods: 'GET, POST, OPTIONS' # 'Accept, Accept-CH, Accept-Charset, Accept-Datetime, Accept-Encoding, Accept-Ext, Accept-Features, Accept-Language, Accept-Params, Accept-Ranges, Access-Control-Allow-Credentials, Access-Control-Allow-Headers, Access-Control-Allow-Methods, Access-Control-Allow-Origin, Access-Control-Expose-Headers, Access-Control-Max-Age, Access-Control-Request-Headers, Access-Control-Request-Method, Age, Allow, Alternates, Authentication-Info, Authorization, C-Ext, C-Man, C-Opt, C-PEP, C-PEP-Info, CONNECT, Cache-Control, Compliance, Connection, Content-Base, Content-Disposition, Content-Encoding, Content-ID, Content-Language, Content-Length, Content-Location, Content-MD5, Content-Range, Content-Script-Type, Content-Security-Policy, Content-Style-Type, Content-Transfer-Encoding, Content-Type, Content-Version, Cookie, Cost, DAV, DELETE, DNT, DPR, Date, Default-Style, Delta-Base, Depth, Derived-From, Destination, Differential-ID, Digest, ETag, Expect, Expires, Ext, From, GET, GetProfile, HEAD, HTTP-date, Host, IM, If, If-Match, If-Modified-Since, If-None-Match, If-Range, If-Unmodified-Since, Keep-Alive, Label, Last-Event-ID, Last-Modified, Link, Location, Lock-Token, MIME-Version, Man, Max-Forwards, Media-Range, Message-ID, Meter, Negotiate, Non-Compliance, OPTION, OPTIONS, OWS, Opt, Optional, Ordering-Type, Origin, Overwrite, P3P, PEP, PICS-Label, POST, PUT, Pep-Info, Permanent, Position, Pragma, ProfileObject, Protocol, Protocol-Query, Protocol-Request, Proxy-Authenticate, Proxy-Authentication-Info, Proxy-Authorization, Proxy-Features, Proxy-Instruction, Public, RWS, Range, Referer, Refresh, Resolution-Hint, Resolver-Location, Retry-After, Safe, Sec-Websocket-Extensions, Sec-Websocket-Key, Sec-Websocket-Origin, Sec-Websocket-Protocol, Sec-Websocket-Version, Security-Scheme, Server, Set-Cookie, Set-Cookie2, SetProfile, SoapAction, Status, Status-URI, Strict-Transport-Security, SubOK, Subst, Surrogate-Capability, Surrogate-Control, TCN, TE, TRACE, Timeout, Title, Trailer, Transfer-Encoding, UA-Color, UA-Media, UA-Pixels, UA-Resolution, UA-Windowpixels, URI, Upgrade, User-Agent, Variant-Vary, Vary, Version, Via, Viewport-Width, WWW-Authenticate, Want-Digest, Warning, Width, X-Content-Duration, X-Content-Security-Policy, X-Content-Type-Options, X-CustomHeader, X-DNSPrefetch-Control, X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Frame-Options, X-Modified, X-OTHER, X-PING, X-PINGOTHER, X-Powered-By, X-Requested-With, Observe' nginx_cors_allowed_headers: 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,Accept-Language,X-CustomHeader,Content-Range,Range,Observe' -nginx_set_xss_protection: True +# Set them only if the application behind the server does not set them by itself. +nginx_set_xss_protection: False nginx_set_content_security_options: False # Choiches: 'self', 'none', a list of domains nginx_content_security_acl: @@ -99,6 +100,7 @@ nginx_content_security_acl: nginx_set_frame_origin: False # SAMEORIGIN, DENY, '' nginx_x_frame_options: 'SAMEORIGIN' + # Find a set of acceptable defaults for the cache setup nginx_cache_enabled: False diff --git a/templates/nginx-virthost.j2 b/templates/nginx-virthost.j2 index 6d80626..e66cb54 100644 --- a/templates/nginx-virthost.j2 +++ b/templates/nginx-virthost.j2 @@ -48,6 +48,7 @@ server { add_header X-XSS-Protection "1; mode=block;"; {% endif %} {% if nginx_set_frame_origin %} + proxy_hide_header X-Frame-Options; add_header X-Frame-Options "{{ nginx_x_frame_options }}"; {% endif %} {% if nginx_set_content_security_options %} @@ -262,6 +263,7 @@ server { add_header X-XSS-Protection "1; mode=block;"; {% endif %} {% if nginx_set_frame_origin %} + proxy_hide_header X-Frame-Options; add_header X-Frame-Options "{{ nginx_x_frame_options }}"; {% endif %} {% if nginx_set_content_security_options %}