Link https://serversforhackers.com/c/redirect-http-to-https-nginx
i had similar problems like
http://www.example.com giving 400 error The plain HTTP request was sent to HTTPS but
if I type https://www.example.com, it worked fine,
I wanted slove to redirect http to https automatically when the user enters http://www.example.com
decision
I made two server blocks, one for port 80, and the other for SSL 443 in a port 80 block, following the procedure below
server { listen 80; server_name example.com, www.example.com; return 301 https://$host$request_uri; }
and another server block for port 443 for ssl configuration
server { location = /favicon.ico { access_log off; log_not_found off; } listen [::]:443 ipv6only=on default_server ssl; listen 443 ssl; ssl on; ssl_certificate /home/hemanth/examp_com/example.crt; ssl_certificate_key /home/hemanth/ssl/example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
Hemanth SP Mar 08 '19 at 4:15 2019-03-08 04:15
source share