![](/img/trans.png)
[英]Docker + Vue.js + Nginx on Vps Debian/Apache error “Error during SSL Handshake with remote server”
[英]GET: ERR_SSL_PROTOCOL_ERROR nginx + vue.js
在 Google Chrome 的控制台日志中,我收到以下錯誤:
GET https://192.168.1.7:8081/sockjs-node/info?t=1579798623564 net::ERR_SSL_PROTOCOL_ERROR
GET https://192.168.1.7/sockjs-node/info?t=1579798623562 net::ERR_CERT_COMMON_NAME_INVALID
如果在 /etc/nginx/conf/default.conf(Ubuntu 18.04.03 服務器版):
server {
listen 443 ssl http2 default_server;
server_name example.com www.example.com
ssl_certificate /etc/ssl/certs/chained.pem;
ssl_certificate_key /etc/ssl/private/domain.key;
ssl_certificate /etc/ssl/certs/chained.pem;
ssl_certificate_key /etc/ssl/private/domain.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:50m;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=31536000";
location / {
proxy_pass http://192.168.1.7:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
add_header Strict-Transport-Security "max-age=31536000";
location / {
proxy_pass http://192.168.1.7:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
我設置 vue.config.js 如下:
module.exports = {
productionSourceMap: false,
pluginOptions: {
i18n: {
enableInSFC: true
}
},
devServer: {
host: '192.168.1.7',
hot: true,
disableHostCheck: true
}
}
並定義 webpack.config.js 如下:
var path = require('path');
var fs = require('fs');
module.exports = {
https: {
key: fs.readFileSync('/etc/ssl/private/domain.key'),
ca: fs.readFileSync('/etc/ssl/certs/chained.pem')
}
};
更新 1)
在 /etc/nginx/conf.d/default.conf 中修改 http -> https:
location / {
proxy_pass https://192.168.1.7:8081;
所以...我現在的問題是:如何讓 nginx 服務器使用 TLS 進行應答?
我做錯了什么? 如何解決問題?
GET https://192.168.1.7:8081/sockjs-node/info?t=1579798623564 net::ERR_SSL_PROTOCOL_ERROR
...
proxy_pass http://192.168.1.7:8081;
在 nginx 配置中,您訪問192.168.1.7:8081
作為http://
。 在第一行中,您使用https://
訪問相同的 IP:port,這會導致協議錯誤。 雖然對此 IP:port 上的服務器一無所知,但很可能只有http://
可以解釋協議錯誤:嘗試對不使用 TLS 應答的服務器進行 TLS 握手。
GET https://192.168.1.7/sockjs-node/info?t=1579798623562 net::ERR_CERT_COMMON_NAME_INVALID
關於192.168.1.7:443
上的證書一無所知(443 是 https 的默認端口),但很可能此證書不包含192.168.1.7
作為有效的 IP SAN。 但這是使用 URL https://192.168.1.7/
時證書驗證的預期值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.