Force HTTPS Requests: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Overview == How to force all requests to a web server to be secure, i.e. https. == nginx == Add file `/etc/nginx/conf.d/000_https_redirect_custom.conf`: <pre> server {...") |
No edit summary |
||
| Line 5: | Line 5: | ||
== nginx == | == nginx == | ||
Edit the following to the nginx server configuration file, e.g. `/etc/nginx/nginx.conf`: | |||
<pre> | <pre> | ||
server { | server { | ||
listen 80; | listen 80 default_server; | ||
return 301 https://$host$request_uri; | server_name _; | ||
return 301 https://$host$request_uri; | |||
} | } | ||
</pre> | </pre> | ||
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. | |||
[[Category:Web Development]] | [[Category:Web Development]] | ||
Revision as of 00:38, 13 June 2020
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.