开发者

NGINX - redirect from https to http without ssl certificate

I'm setting up a new nginx box however I can't figure out why my nginx isn't starting when I use this:

    server {
    listen      443;
    server_name mysite.com; // https://mysite.com
    r开发者_运维知识库ewrite ^(.*)   https://mynewsite.com.com$1 permanent; // new site
}

Anyone help me out?


This is impossible to do. Redirecting from https to http itself is based on a successful https connection, which requires a certificate.


if you have an SSL either purchased one or self signed SSL, you can then redirect the https to http. yes, you can redirect https to http without SSL if someone try adding the s letter in your url so that your url can't serve anything over HTTPS, but only HTTP

server {
    listen 443;
    server_name yourdomain.com;
    return 301 http://www.yourdomain.com;
}

and you need to have another server block to complete the www servingon your url.

server {
        listen 443;
        server_name www.yourdomain.com;
        // the rest of your configs //
    }

I hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜