我有两个虚拟机。第一个是 VM1,第二个是 VM2。第一个是 VPN 服务器,第二个是客户端。在 VM1 上,Nginx 安装在官方 Docker 存储库中作为反向代理。在 VM2 上,Nginx 安装在nginx-proxy Docker 存储库。我尝试建立从 VM1 到 VM2 的 SSL 连接,但收到错误
curl:(35)错误:1408F10B:SSL 例程:ssl3_get_record:版本号错误
VM1 的 Nginx 配置(将所有查询从 80 和 443 重定向到 VM2)
server {
listen 80;
listen [::]:80;
server_name _;
location / {
proxy_pass http://vm2-client-ip:80;
}
}
server {
listen 443;
listen [::]:443;
server_name _;
location / {
proxy_pass http://vm2-client-ip:443;
}
}
在 VM2 上,nginx-proxy 生成下一个配置:
# whoami.my-domain.com
upstream whoami.my-domain.com {
## Can be connected with "home-network" network
# who-am-i
server 10.0.0.2:80;
}
server {
server_name whoami.my-domain.com;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
# Do not HTTPS redirect Let'sEncrypt ACME challenge
location ^~ /.well-known/acme-challenge/ {
auth_basic off;
auth_request off;
allow all;
root /usr/share/nginx/html;
try_files $uri =404;
break;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
server_name whoami.my-domain.com;
listen 443 ssl http2 ;
access_log /var/log/nginx/access.log vhost;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_certificate /etc/nginx/certs/whoami.my-domain.com.crt;
ssl_certificate_key /etc/nginx/certs/whoami.my-domain.com.key;
ssl_dhparam /etc/nginx/certs/whoami.my-domain.com.dhparam.pem;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/nginx/certs/whoami.my-domain.com.chain.pem;
add_header Strict-Transport-Security "max-age=31536000" always;
include /etc/nginx/vhost.d/default;
location / {
proxy_pass http://whoami.my-domain.com;
}
}
SSL 证书是通过这个存储库. 根据此容器的日志,证书生成成功。
HTTP 连接运行良好。PS 如果这是个问题,两个 Nginx 都可以从容器中运行。