Difference between revisions of "Configure HTTP to HTTPs redirection with Nginx"
Jump to navigation
Jump to search
(Created page with " Ref: https://bjornjohansen.no/redirect-to-https-with-nginx <pre> server { listen 80 default_server; listen [::]:80 default_server; server_name example.com www.example.com;...") |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Ref: https://bjornjohansen.no/redirect-to-https-with-nginx | Ref: https://bjornjohansen.no/redirect-to-https-with-nginx | ||
+ | |||
+ | |||
+ | |||
+ | server { | ||
+ | listen 80 default_server; | ||
+ | listen [::]:80 default_server; | ||
+ | server_name _; | ||
+ | [[return]] [[301]] https://$host$request_uri; | ||
+ | } | ||
+ | |||
+ | |||
<pre> | <pre> | ||
− | server { | + | server { |
listen 80 default_server; | listen 80 default_server; | ||
listen [::]:80 default_server; | listen [::]:80 default_server; | ||
server_name example.com www.example.com; | server_name example.com www.example.com; | ||
return 301 https://$server_name$request_uri; | return 301 https://$server_name$request_uri; | ||
− | } | + | } |
</pre> | </pre> | ||
+ | |||
+ | |||
+ | |||
+ | == See also == | ||
+ | * [[MITM]] | ||
+ | * {{nginx}} | ||
+ | * {{HTTPS}} | ||
+ | |||
+ | |||
+ | [[Category:Nginx]] |
Latest revision as of 12:29, 26 August 2021
Ref: https://bjornjohansen.no/redirect-to-https-with-nginx
server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 301 https://$host$request_uri; }
server { listen 80 default_server; listen [::]:80 default_server; server_name example.com www.example.com; return 301 https://$server_name$request_uri; }
See also[edit]
- MITM
- Web server: Nginx:
/etc/nginx/nginx.conf
,nginx -t
, Nginx logs, Nginx change log, PHP,php-fpm
, Let's encrypt, Nginx directives, Reverse Proxy, Configure HTTP redirection Nginx, Return,proxy_pass (Reverse proxy)
,ngx_http_rewrite_module
,/etc/nginx/sites-enabled/
,error.log
,access.log
,/nginx status
, AIO - HTTP, HTTP client, HTTP/1.1, HTTP/2, HTTP/3, HTTPS, HSTS CSR, TLS, SSL,
openSSL
, WebSockets, WebRTC,ssl_certificate
QUIC, HPKP, CT, List of HTTP status codes, URL redirection, Content-type:, Webhook, HTTP headers,--insecure
, Axios HTTP client, HTTP cookies, HTTP ETag
Advertising: