本文介绍了nginx 将 HTTPS 重定向到 HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 https 重定向到 http?
How can i redireect from https to http?
我有下面的代码,但它似乎不起作用.
i have the code below but it does not seem to work.
server {
listen 443;
server_name example.com;
rewrite ^(.*) http://example.com$1 permanent;
}
推荐答案
上面的答案会起作用,您需要生成一个自签名证书(或拥有一个真实的)并像这样配置 nginx:
The answer above will work, you need to generate a self signed cert (or have a real one) and configure nginx as such:
server {
listen *:443;
ssl on;
server_name domain.com;
rewrite ^(.*) http://domain.com$1 permanent;
ssl_certificate /data/certs/domain.crt;
ssl_certificate_key /data/certs/domain.key;
}
请记住,如果它是自签名证书,浏览器会给您一个丑陋的警告.
Keep in mind, if it is a self signed cert the browser will give you an ugly warning.
这篇关于nginx 将 HTTPS 重定向到 HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!