在 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/
.
我的情况非常相似。 我的网站在 http 上运行,在 https 上运行失败。 将 nginx 更改为 https 的修复将不起作用,因为您正在路由到 nginx 未知的 URL。因此出现错误的网关错误。 我在 nginx 配置中看到了一些东西
proxy_ssl_verify 关闭;
尝试在服务器位置/{} 块上的 nginx 中添加它。
另请注意,这对我不起作用,但我发现这是合乎逻辑的解决方案。 另外,如果你解决了你的问题,你能不能也帮我说说你到底做了什么?