简体   繁体   English

带有 HTTP 和 HTTPS 但没有重定向的 Nginx

[英]Nginx with HTTP and HTTPS but no redirect

I somehow inherited a Nginx configuration and I want to have both http and https on it in some situations.我以某种方式继承了 Nginx 配置,并且在某些情况下我希望同时使用 http 和 https。 The problem is that the http variant redirects to https always and the https handshake fails since it is not yet configured.问题是 http 变体总是重定向到 https 并且 https 握手失败,因为它尚未配置。

Where is this redirect coming from if not my /etc/nginx/sites-enabled/default?如果不是我的 /etc/nginx/sites-enabled/default,这个重定向来自哪里? My /etc/nginx/conf.d is empty and I see nothing in /etc/nginx/nginx.conf that is remotely similar to a redirect.我的 /etc/nginx/conf.d 是空的,我在 /etc/nginx/nginx.conf 中看不到任何类似于重定向的内容。 I even tried commenting the entire HTTPS server block and it still redirects.我什至尝试评论整个 HTTPS 服务器块,它仍然重定向。

I want to have a development environment in Vagrant with only HTTP.我想在 Vagrant 中拥有一个只有 HTTP 的开发环境。 The testing and production versions need to start off with HTTP and no redirect so that after I generate a Let's Encrypt certificate it will enable the redirect to HTTPS but not before I get the certificate.测试和生产版本需要从 HTTP 开始,没有重定向,这样在我生成 Let's Encrypt 证书后,它将启用到 HTTPS 的重定向,但不是在我获得证书之前。 The Let's Encrypt certificate generation protocol (ACME) needs me to server HTTPS content. Let's Encrypt 证书生成协议 (ACME) 需要我来处理 HTTPS 内容。

Here is my Nginx configuration, I'm using Ansible for provisioning. 是我的 Nginx 配置,我使用 Ansible 进行配置。

How can I disable the HTTP to HTTPS redirect?如何禁用 HTTP 到 HTTPS 重定向? How can I debug this?我该如何调试? Thank you!谢谢!

I fixed it myself.我自己修好了。 I have been trying to fix it for two days before asking on StackOverflow.在询问 StackOverflow 之前,我已经尝试修复它两天了。

I've been troubleshooting the Nginx config and it all seems ok because it IS OK!我一直在对 Nginx 配置进行故障排除,看起来一切正常,因为它没问题! As I said I inherited the whole stack, not just Nginx and since it is not the Nginx config it can only mean the app does this.正如我所说,我继承了整个堆栈,而不仅仅是 Nginx,而且由于它不是 Nginx 配置,因此只能意味着应用程序执行此操作。 Check this out: FORCE_SSL: true看看这个: FORCE_SSL: true

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

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