首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ERR_SSL_UNRECOGNIZED_NAME_ALERT Nginx

ERR_SSL_UNRECOGNIZED_NAME_ALERT Nginx
EN

Stack Overflow用户
提问于 2022-05-04 04:36:41
回答 1查看 1.6K关注 0票数 0

我使用的是Laravel,并停止使用它,因为我的卡有问题。所以我继续我自己的数字海洋。

我按照下面的instructable对站点应用SSL。https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04-es

这个过程显示了一些错误,例如:

代码语言:javascript
运行
复制
maquino@codigobyte:/etc/nginx/sites-enabled$ sudo nginx -t
nginx: [warn] conflicting server name "todocontenidoweb.com" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.todocontenidoweb.com" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "todocontenidoweb.com" on [::]:80, ignored
nginx: [warn] conflicting server name "www.todocontenidoweb.com" on [::]:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

问题是,我的网站已经关闭,我已经在第三天和数字海洋支持告诉我,他们没有看到一个问题的配置。但是网站已经关闭了。在下一页中,它向我展示了安全连接的一个问题。

https://www.ssllabs.com/ssltest/analyze.html?d=todocontenidoweb.com

目前,有几件事情让我相信在以下配置中存在问题: in /etc/nginx/ site -启用了$我有3个文件,其中之一是我的站点todocontenidoweb.com In todocontenidoweb.com:

代码语言:javascript
运行
复制
server {
listen 80;
listen [::]:80;
server_name todocontenidoweb;
server_tokens off;
root /home/forge/todocontenidoweb.com/public;

在server_name行中,所有web内容;我知道我应该放置todocontenidoweb.com www.todocontenidos web.com,但是它不允许我,如果我这样做,它会给我证书中的一个错误。如果有人能帮我解决这个问题,我会非常感激的。

文件:/etc/nginx/sites现有/mydomain.com

代码语言:javascript
运行
复制
# FORGE CONFIG (DO NOT REMOVE!)
#include forge-conf/todocontenidoweb.com/before/*;

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    include snippets/self-signed.conf;
    include snippets/ssl-params.conf;

    server_name todocontenidoweb.com www.todocontenidoweb.com;
    server_tokens off;
    root /home/forge/todocontenidoweb.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    # ssl_protocols TLSv1.2 TLSv1.3;
    # ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY13>
    # ssl_prefer_server_ciphers off;
    # ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    #include forge-conf/todocontenidoweb.com/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/todocontenidoweb.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

server {
    listen 80;
    listen [::]:80;

    server_name todocontenidoweb.com www.todocontenidoweb.com;

    return 302 https://$server_name$request_uri;
}

# FORGE CONFIG (DO NOT REMOVE!)
#include forge-conf/todocontenidoweb.com/after/*;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-04 07:38:00

//编辑

如下所示,该站点将返回301响应并重定向到https站点,但您的nginx信任没有一个在端口443上运行。

//编辑结束

您的nginx配置似乎有问题。看起来您的配置只允许端口80,而不是443。浏览器期望将443作为端口(除非您另外指定)作为ssl端口。似乎您正在使用一些重定向将用户从http重定向到https,唯一的问题是您没有在端口443上运行任何https服务。

我可能是你的nginx配置的问题。确保具有ssl输入的server条目也运行在端口443上。

如果您安装了ssl,让我们加密,您可以尝试手动生成证书,然后您可以修改nginx 配置以ssl形式在端口443上运行。

您可以从数字海洋跟踪本指南,只需将证书路径替换为lets encrypt one即可。

编辑2:

我认为这部分不应该被删掉

代码语言:javascript
运行
复制
    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    # ssl_protocols TLSv1.2 TLSv1.3;
    # ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY13>
    # ssl_prefer_server_ciphers off;
    # ssl_dhparam /etc/nginx/dhparams.pem;

因为您实际上没有通过443端口提供任何ssl证书。

下面是来自DigitalOcean的一个示例服务器。如你所见,他们提供的是私钥和公钥。生成证书后,需要输入这些证书的路径。

代码语言:javascript
运行
复制
server {
    listen 443 http2 ssl;
    listen [::]:443 http2 ssl;

    server_name your_server_ip;

    ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
    ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
}

编辑结束

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72108003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档