Redirect HTTP to HTTPS on the same port

This configuration allows to redirect any HTTP connection to HTTPS, on the same port. This is useful when using a custom port.

I'm adding this config here because it needs to be included in every server configuration, not just the main one, and this file is included in each website configuration.
This commit is contained in:
Oliver Cervera 2021-02-25 12:18:02 +01:00 committed by GitHub
parent 30d407e922
commit cd3cb06c6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,9 @@ ssl_early_data on;
# HSTS, remove # from the line below to enable HSTS
#add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
# Redirect http traffict to https on same port
error_page 497 301 =307 https://$host:$server_port$request_uri;
# Optional additional headers
#add_header Cache-Control "no-transform" always;
#add_header Content-Security-Policy "upgrade-insecure-requests; frame-ancestors 'self'";