Force HTTPS Requests
Overview
How to force all requests to a web server to be secure, i.e. https.
nginx
Edit the following to the nginx server configuration file, e.g. /etc/nginx/nginx.conf:
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
Some sources claim that this can be put into a separate configuration file, e.g. /etc/nginx/conf.d/000_https_redirect_custom.conf, but I did not have luck doing this. http and https requests were still both successfully, but http requests were not redirected.