我有兩個虛擬機器。第一個是 VM1,第二個是 VM2。第一個是 VPN 伺服器,第二個是客戶端。在 VM1 上,Nginx 作為官方 Docker 儲存庫的反向代理安裝。在 VM2 上,Nginx 作為反向代理安裝nginx-proxy Docker 儲存庫。我嘗試設定從 VM1 到 VM2 的 SSL 連接,但收到錯誤
捲曲:(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 都可以在容器中工作。