小编pea*_*ker的帖子

Nginx 负载均衡器挂在 SSL 上

我试图让 nginx 在我的 Web 服务器之间进行负载平衡,同时在负载平衡器级别终止 SSL。我正在使用的 nginx.conf 文件基于做这件事的所有指南,但我无法让它工作。使用标准 HTTP 时,负载均衡器工作正常。但是,当尝试通过 HTTPS 访问负载均衡器时,浏览器会挂起,最终给出 ERR_CONNECTION_REFUSED。

我在尝试 HTTPS 时没有看到日志中的任何错误,甚至在访问日志中也没有看到任何错误,所以我不知道可能是什么问题。我尝试了很多不同的配置选项,包括尝试不同的 SSL 证书、PEM 编码、捆绑证书等等,但都没有效果。

这是 nginx.conf 的主要部分:

upstream backend {
    #web01
    server 10.01.01.102;
    #web02
    server 10.02.02.77;
}

#setup proxy
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# standard http server
server {
    listen 80;
    listen 4444;

    server_name *.example.com;

    location / {
        proxy_pass http://backend;
    }
}

#server for https requests
server {
    listen 443 ssl;

    server_name *.example.com;

    #ssl on;
    ssl_certificate /path/to/example.com.crt;
    ssl_certificate_key /path/to/example.com.key;

    location …
Run Code Online (Sandbox Code Playgroud)

ssl nginx load-balancing

3
推荐指数
1
解决办法
3627
查看次数

标签 统计

load-balancing ×1

nginx ×1

ssl ×1