Skip to content

Commit 44b4250

Browse files
authored
Merge pull request #65 from macbre/set-security-headers
nginx.conf: set security-related response headers
2 parents 9d163bb + a47fa41 commit 44b4250

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

nginx.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,22 @@ http {
3232

3333
keepalive_timeout 65;
3434

35+
# security, reveal less information about ourselves
3536
server_tokens off; # disables emitting nginx version in error messages and in the “Server” response header field
3637
more_clear_headers 'Server';
38+
more_clear_headers 'X-Powered-By';
3739

40+
# prevent clickjacking attacks
41+
more_set_headers 'X-Frame-Options: SAMEORIGIN';
42+
43+
# help to prevent cross-site scripting exploits
44+
more_set_headers 'X-XSS-Protection: 1; mode=block';
45+
46+
# help to prevent Cross-Site Scripting (XSS) and data injection attacks
47+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
48+
more_set_headers "Content-Security-Policy: object-src 'none'; frame-ancestors 'self'; form-action 'self'; block-all-mixed-content; sandbox allow-forms allow-same-origin allow-scripts allow-popups allow-downloads; base-uri 'self';";
49+
50+
# enable response compression
3851
gzip on;
3952
brotli on;
4053
brotli_static on;

0 commit comments

Comments
 (0)