AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1023579
Accepted
Sz3jdii
Sz3jdii
Asked: 2020-07-02 01:50:06 +0800 CST2020-07-02 01:50:06 +0800 CST 2020-07-02 01:50:06 +0800 CST

Nginx 负载均衡器在代理传递 SSL 流量时抛出 502 错误

  • 772

我有两个配置如下的 debian 10 服务器。10.0.0.3 是基于 nginx 和端口转发(80、443)的负载均衡器。10.0.0.2 是代理后面的服务器之一,我想代理流量。负载均衡器 nginx 配置:

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name _;
        return 301 https://$host$request_uri;
}

server {
        listen 443 ssl default_server;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
        location / {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_pass https://10.0.0.2;
        }

}

和 10.0.0.2 服务器上 phpmyadmin 的示例配置

server {
    server_name pma.example.com www.pma.example.com;
    root /usr/share/phpMyAdmin;
    access_log /var/log/nginx/access_pma.example.com.log;
    error_log /var/log/nginx/error_pma.example.com.log;

    satisfy  any;
    allow 8.8.8.8;
    deny   all;

    auth_basic "Administrator’s Area";
    auth_basic_user_file /etc/apache2/.htpasswd;


    client_max_body_size 4m;

    location / {
        try_files $uri /index.php?$query_string;
    }
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
       access_log off;
       expires 30d;
    }

    location ~ /\.ht {
       deny all;
    }

    location ~ /(libraries|setup/frames|setup/libs) {
       deny all;
       return 404;
    }
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/var/run/php/php7.4-fpm_pma.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
 location ~ /\.(?!well-known).* {
        deny all;
    }



    listen 443 ssl;
     include snippets/self-signed.conf;
    include snippets/ssl-params.conf;

}

我得到的错误是 502,来自负载均衡器的日志如下所示:

2020/07/01 11:48:22 [error] 21623#21623: *6 peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream, client: xxxx, server: , request: "GET / HTTP/1.1", upstream: "https://10.0.0.2:443/", host: "pma.example.com"
2020/07/01 11:48:22 [error] 21623#21623: *6 peer closed connection in SSL handshake while SSL handshaking to upstream, client: xxxx, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "https://10.0.0.2:443/favicon.ico", host: "pma.example.com", referrer: "https://pma.example.com/"

感谢您的任何帮助!:)

load-balancing nginx
  • 1 1 个回答
  • 411 Views

1 个回答

  • Voted
  1. Best Answer
    Sz3jdii
    2020-07-15T02:48:59+08:002020-07-15T02:48:59+08:00

    问题是服务器名称根本没有通过,所以后端服务没有解析请求。我已经在 dnsmasq 中运行了 dnsmasq 并使用通配符规则转发了服务器名

    • 0

相关问题

  • 网络负载平衡服务器无法相互通信

  • 用于网络监控的路由/代理 SNMP 陷阱(或 Netflow、通用 UDP 等)的解决方案?

  • 防止拒绝服务攻击的最佳技术是什么?

  • 添加备份互联网连接需要哪些硬件?

  • 什么是最有效的 Windows 负载平衡解决方案?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve