ninety-seven
Nginx automatically jumps to HTTPS

Modify Nginx configuration file

Example 1

 rewrite ^(.*)$ //$host$1 permanent;

Example 2

Applicable to port 80 and 443 configured in the same server {}

 if ($server_port = 80) {
rewrite ^(.*)$ //$host$1 permanent;
}

Example 3 Many domain names are bound to the site, and only one domain name is allowed to jump:

 set $redirect_https 1;
if ($server_port = 80) {
set $redirect_https "$ {redirect_https}2 ";
}
if ($http_host = 'www.exampledemo.com') {
set $redirect_https "$ {redirect_https}3 ";
}
if ($http_host = 'exampledemo.com') {
set $redirect_https "$ {redirect_https}3 ";
}
if ($redirect_https = "123") {
rewrite ^(.*)$ //$host$1 permanent;
}

Configuration example Configuration example:

 server {
listen 80;
server_name www.exampledemo.cn;
rewrite ^ //$http_host$request_uri? permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/cacert.pem;
ssl_certificate_key /etc/ssl/privkey.pem;
server_name www.exampledemo.cn;
server_tokens off;
location / {
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
}
}

Does this help solve your problem? resolved Unresolved

Submitted successfully! Thank you very much for your feedback, and we will continue to strive to do better! We are sorry that we were unable to resolve your question. We have received your feedback and will give feedback in time!