GET: ERR_SSL_PROTOCOL_ERROR nginx + vue. js - PullRequest
0 голосов
/ 23 января 2020

В консольном журнале 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

enter image description here

, если в / etc / nginx / conf /default.conf (Ubuntu 18.04.03 Server Edition):

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;

ведет к 502 Bad Gateway: enter image description here

Итак ... мой вопрос сейчас: как заставить сервер nginx ответить с помощью TLS?

Что я делаю неправильно? Как решить проблему?

1 Ответ

0 голосов
/ 23 января 2020
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://´. In the first line you access the same IP:port with https: // which results in a protocol error. While nothing is known about the server on this IP:port it is very likely that is only 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/.

...