简体   繁体   English

NGINX - 在没有 ssl 证书的情况下从 https 重定向到 http

[英]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:我正在设置一个新的 nginx 框,但是我不知道为什么我的 nginx 在我使用它时没有启动:

    server {
    listen      443;
    server_name mysite.com; // https://mysite.com
    rewrite ^(.*)   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.从 https 重定向到 http 本身是基于成功的 https 连接,这需要证书。

if you have an SSL either purchased one or self signed SSL, you can then redirect the https to http.如果您购买了 SSL 或自签名 SSL,则可以将 https 重定向到 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是的,如果有人尝试在您的 url 中添加s字母,您可以在没有 SSL 的情况下将 https 重定向到 http,这样您的 url 就不能通过 HTTPS 提供任何服务,而只能通过 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.并且您需要有另一个服务器块来完成您的 url 上的www服务。

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

I hope that helps.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM