nginx:setting_up_hsts_in_nginx
Differences
This shows you the differences between two versions of the page.
nginx:setting_up_hsts_in_nginx [2016/10/07 15:46] – created peter | nginx:setting_up_hsts_in_nginx [2019/11/29 16:20] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== NginX - HTTPS Strict Transport Security (HSTS) ====== | ||
- | The HTTP Strict Transport Security (HSTS) header allows a host to enforce the use of HTTPS on the client side. By informing the browser to only use HTTPS, even if the user specifies HTTP as the protocol, the browser will enforce the use of HTTPS. | ||
- | |||
- | HSTS, coupled with server side redirection from HTTP to HTTPS, offers a more robust implementation of SSL as the browser is now aware that you expect secure comms. | ||
- | |||
- | |||
- | ===== NginX - Setting up HSTS in NginX ===== | ||
- | |||
- | To be fully HSTS compliant a host should only issue a HSTS header over a secure transport layer. This is because an attacker can maliciously strip out or inject a HSTS header into insecure traffic. For that reason, a browser should also disregard any HSTS headers received via HTTP, so technically it shouldn' | ||
- | |||
- | <code nginx> | ||
- | add_header Strict-Transport-Security " | ||
- | </ | ||
- | |||
- | ...and as it would be within a config file... | ||
- | |||
- | <code nginx> | ||
- | server { | ||
- | listen 443 ssl; | ||
- | server_name sharewiz.net; | ||
- | add_header Strict-Transport-Security " | ||
- | ... | ||
- | } | ||
- | </ | ||
- | |||
- | The **' | ||
- | |||
- | The optional **' | ||
- | |||
- | The optional **always** parameter ensures that the header is set for all responses, including internally-generated error responses. | ||
- | |||
- | |||
- | Don't forget to restart NginX. | ||
- | |||
- | <code bash> |
nginx/setting_up_hsts_in_nginx.1475855208.txt.gz · Last modified: 2020/07/15 09:30 (external edit)