简体   繁体   English

Docker ERR_SSL_PROTOCOL_ERROR

[英]Docker ERR_SSL_PROTOCOL_ERROR

I have 2 docker containers running on a server:我有 2 个 docker 容器在服务器上运行:

  1. Frontend Vue.js app (0.0.0.0:6336 -> 443/tcp)前端 Vue.js 应用程序(0.0.0.0:6336 -> 443/tcp)
  2. Express Backend (0.0.0.0:8000 -> 443/tcp) Express 后端(0.0.0.0:8000 -> 443/tcp)

When the frontend tries to communicate with the backend, with this request:当前端尝试与后端通信时,使用此请求:

https://host:8000/query

I'm getting this error:我收到此错误:

net::ERR_SSL_PROTOCOL_ERROR净:: ERR_SSL_PROTOCOL_ERROR

The backend has a certificate applied to it like so:后端应用了一个证书,如下所示:

app = https.createServer({
    key: fs.readFileSync('private_key.key', 'utf8'),
    cert: fs.readFileSync('cert.crt', 'utf8')
}, app)

If I run both of these apps locally, it works fine.如果我在本地运行这两个应用程序,它工作正常。 I feel like this is a simple fix but I'm pretty new to Docker so I don't know where to begin.我觉得这是一个简单的修复,但我对 Docker 还很陌生,所以我不知道从哪里开始。

If I change it to http , I get this error:如果我将其更改为http ,则会出现此错误:

xhr.js:178 Mixed Content: The page at 'https://host:6336/#/search?subject=a' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://host:8000/query'. xhr.js:178 混合内容:位于“https://host:6336/#/search?subject=a”的页面已通过 HTTPS 加载,但请求了不安全的 XMLHttpRequest 端点“http://host:8000/query” . This request has been blocked;此请求已被阻止; the content must be served over HTTPS.内容必须通过 HTTPS 提供。

My problem was adding the listen statement before the https server was created, I didn't realize that the order mattered.我的问题是在创建https服务器之前添加listen语句,我没有意识到顺序很重要。 Before it was like this:之前是这样的:

var app = express()

app.listen(PORT, function() {
  console.log(`Listening on port ${PORT}...`)
});

const options = {
  key: fs.readFileSync(keyPath, 'utf8'),
  cert: fs.readFileSync(certPath, 'utf8')
}
app = https.createServer(options, app)

return app

The listen should come after creating the https server: listen应该在创建https服务器之后进行:

var app = express()

const options = {
  key: fs.readFileSync(keyPath, 'utf8'),
  cert: fs.readFileSync(certPath, 'utf8')
}
app = https.createServer(options, app)

app.listen(PORT, function() {
  console.log(`Listening on port ${PORT}...`)
});

return app

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 socket.io 错误网络::ERR_SSL_PROTOCOL_ERROR - socket.io error net::ERR_SSL_PROTOCOL_ERROR 在 axios reactJs 中获取 net::ERR_SSL_PROTOCOL_ERROR - getting net::ERR_SSL_PROTOCOL_ERROR in axios reactJs 向服务器 IP 发出请求时出现 ERR_SSL_PROTOCOL_ERROR - ERR_SSL_PROTOCOL_ERROR when making request to server IP http POST 上的 net::ERR_SSL_PROTOCOL_ERROR 到快递服务器 - net::ERR_SSL_PROTOCOL_ERROR on http POST to express server ERR_SSL_PROTOCOL_ERROR 仅适用于某些用户(nodejs,express) - ERR_SSL_PROTOCOL_ERROR only for some users (nodejs, express) ERR_SSL_PROTOCOL_ERROR | 完整应用(背面+正面) - ERR_SSL_PROTOCOL_ERROR | Full aplication (back + front) 具有SSL的Azure辅助角色上的Node.js导致ERR_SSL_PROTOCOL_ERROR - Node.js on Azure Worker Role w/ SSL results in ERR_SSL_PROTOCOL_ERROR Nginx 代理到 node.js 服务器 SSL ERR_SSL_PROTOCOL_ERROR - Nginx proxy to node.js server SSL ERR_SSL_PROTOCOL_ERROR 在Node.js Express中运行https服务器时出现ERR_SSL_PROTOCOL_ERROR浏览器错误消息 - ERR_SSL_PROTOCOL_ERROR browser error message while running a https server in nodejs express 连接建立错误:尝试建立并连接到Websocket服务器时,抛出net :: ERR_SSL_PROTOCOL_ERROR - Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR is thrown when trying establish and connect to a websocket server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM