docker - 'LibreSSL SSL_connect : SSL_ERROR_SYSCALL' on curl to NGINX reverse proxy on a Docker Container

标签 docker ssl nginx-reverse-proxy

我能够在启用 SSL 的情况下成功获得本地运行的 NGINX 反向代理。但是,一旦我尝试让它在 Docker 容器上运行,我就会遇到 SSL 问题。

我使用 docker run -it nginxProxy -v local_path_to_certs:container_path_to_certs -p 9443:443 端口转发到端口 9443 .

我的 Dockerfile:

FROM nginx:alpine

# Expost port 443
EXPOSE 443

RUN rm -v /etc/nginx/nginx.conf
RUN rm -rf /etc/nginx/conf.d

# Copy custom configuration file from the current directory
COPY nginx.conf /etc/nginx/nginx.conf

ENTRYPOINT [ "nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]

我的 nginx.conf:
events {
    worker_connections 1024;
}


http {

  ssl_session_cache  builtin:1000  shared:SSL:10m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4:!SHA:!SHA1:!SSLv2:@STRENGTH;
  ssl_prefer_server_ciphers on;

  ssl_certificate           /path_to_cert/public.cert.pem;
  ssl_certificate_key       /path_to_private_key/private.key.pem;
  ssl_password_file         /path_to_password_file/password.txt;

  server {
    listen [::]:443 ssl;

    server_name _;

    location / {
       proxy_pass https://example.com; 

    }
  }
}

在我的本地机器上,这和预期的一样好,但是在运行 curl https://localhost:9443 -vvv 的 Docker 容器上运行时给我
* Rebuilt URL to: https://localhost:9443/
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:9443 
* Closing connection 0
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:9443 

最佳答案

我假设你现在已经解决了这个问题。无论哪种方式,我都会留下寻找相同问题的解决方案。
我遇到了类似的错误,用户 mljrg 发现它是在将主机名解析为 IPv6 地址时发生的。他通过比较两台机器的输出发现了这一点,一台解析为 IPv4 并且在那里工作,另一台解析为 IPv6 并且在那里失败。
所以解决方案是在 macOS High Sierra 10.13.6 上运行 networksetup -setv6off Wi-Fi。
也许这有助于像我这样的其他一些人。

关于docker - 'LibreSSL SSL_connect : SSL_ERROR_SYSCALL' on curl to NGINX reverse proxy on a Docker Container,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57406139/

相关文章:

node.js - 如何使用 jwilder/nginx-proxy 设置反向代理?

docker - 如何正确配置NGINX作为tine20 docker容器(与Apache2一起运行)的反向代理?

docker - 使用本地文件在 Windows 上构建 docker 镜像时使用 --squash 的替代方法

java - 为docker和应用程序设置不同的配置文件是JDBC连接

git - Docker是否替代了git源代码控制?

node.js - 使用 Node.js 的 Azure 网站的 SSL 端口?

ssl - 强制安全浏览

android - 无法在 Android 默认模拟器或 Genymotion 上安装自签名证书

nginx反向代理禁用缓存

docker - 在 docker alpine 上安装软件包时无法满足的约束