redirect - 我如何在 nginx 负载均衡器上将 https 重定向到 http

标签 redirect ssl nginx load-balancing

我正在使用 nginx 负载平衡器,我希望我的所有请求都从 https 重定向到 http

这是负载均衡器的配置方式 -

upstream web_app_backend {
    ip_hash;
    server app1.example.com;
    server app2.example.com;
}

server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate /etc/nginx/ssl/example.crt;
    ssl_certificate_key /etc/nginx/ssl/example.com.key;
    return 302 http://example.com$request_uri;
}

server {
    listen 80;
    server_name example.com;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        proxy_pass  http://web_app_backend;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
    }
}

最佳答案

事实证明,我的 443 端口被防火墙阻止了。 nginx配置没问题。

关于redirect - 我如何在 nginx 负载均衡器上将 https 重定向到 http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40782479/

相关文章:

wordpress -/wp-admin/&/wp-login.php 重定向循环

java - HttpClient 用于相对重定向的自定义重定向处理程序

linux - unix下的多个输入文本文件作为stdin

python - 在 Ubuntu 上通过 FastCGI 和 nginx 运行 Python

apache - Rewriterule 默认重定向到 http

php - Laravel 10 测试电子邮件与 EsmtpTransport 类的连接

c++ - 使用 OpenSSL 构建 QT 期间出错

ssl - SSL 模式下的 Nginx 配置文件中没有信息

dictionary - 如何在 nginx 中创建异步 "cron like"调度器

spring - Shiro,Spring 应用程序将 jsessionid 附加到每个 URL