我已根据https://docs.mongodb.org/manual/core/security-transport-encryption/配置MongoDB以使用SSL。它工作正常。
现在我需要把它放在nginx后面。 当我使用以下配置时:
server {
listen 27017;
server_name mysite.com;
location / {
proxy_pass http://localhost:12345/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
client_max_body_size 110m;
}
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
}
当我尝试连接时,我收到了:
{com.mongodb.MongoException $ Network:打开套接字的异常},由 {javax.net.ssl.SSLException:无法识别的SSL消息,明文连接?}
所以我添加了nginx ssl指令:
server {
listen 27017 ssl;
server_name mysite.com;
location / {
proxy_pass http://localhost:12345/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
client_max_body_size 110m;
}
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
}
之后我收到了:
{com.mongodb.MongoException $ Network:打开套接字的异常},由 {javax.net.ssl.SSLHandshakeException:握手期间远程主机关闭连接},由 {java.io.EOFException:SSL对等关闭错误}
有人可以帮我吗?