nginx将HTTPS重定向到HTTP [英] nginx redirect HTTPS to HTTP

查看:646
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆