加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

带有Nginx和Chrome的通配符* .localhost SSL

发布时间:2020-12-13 21:20:01 所属栏目:Nginx 来源:网络整理
导读:我尝试使用Nginx代理对localhost:3000的请求为HTTP和HTTPS设置通配符* .localhost. DNSmasq用于将* .localhost解析为127.0.0.1. 一切都适用于HTTP,但HTTPS连接在Google Chrome中收到以下错误: There are issues with the site's certificate chain (net::E

我尝试使用Nginx代理对localhost:3000的请求为HTTP和HTTPS设置通配符* .localhost. DNSmasq用于将* .localhost解析为127.0.0.1.

一切都适用于HTTP,但HTTPS连接在Google Chrome中收到以下错误:

There are issues with the site's certificate chain (net::ERR_CERT_COMMON_NAME_INVALID).

该证书是我通过设置添加到Chrome的自签名证书,并使用以下命令生成:

openssl req -x509 -sha256 -newkey rsa:2048 -keyout localhost.key -out localhost.crt -days 3650 -nodes

主题如下:

Subject: C=AU,ST=Western Australia,L=Perth,O=Zephon,CN=*.localhost

我的Nginx配置如下:

server {
    listen       80;
    listen       443 ssl; 

    server_name  localhost;

    ssl_certificate /etc/nginx/ssl/localhost.crt;
    ssl_certificate_key /etc/nginx/ssl/localhost.key;

    location / {
        proxy_pass          http://localhost:3000;
        proxy_http_version  1.1;
        proxy_set_header    Host             $host;
        proxy_set_header    Upgrade          $http_upgrade;
        proxy_set_header    Connection       "upgrade";
        proxy_set_header    X-Real-IP        $remote_addr;
        proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header    X-Client-Verify  SUCCESS;
        proxy_set_header    X-Client-DN      $ssl_client_s_dn;
        proxy_set_header    X-SSL-Subject    $ssl_client_s_dn;
        proxy_set_header    X-SSL-Issuer     $ssl_client_i_dn;
        proxy_read_timeout 1800;
        proxy_connect_timeout 1800;
    }
}
最佳答案
因此,最终答案似乎是您无法为Chrome将接受的* .localhost创建证书.

我的解决方案是改为使用* .dev.localhost代替,这是一种享受.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读