在Nginx NET上的LetsEncrypt :: ERR_CERT_COMMON_NAME_INVALID

时间:2018-12-24 13:46:27

标签: nginx ssl-certificate lets-encrypt nginx-location nginx-config

我尽一切努力解决了这个问题,但是似乎没有任何效果。 花了几个小时解决这个问题。

我有带有nginx 1.14.0的Ubuntu 18.04服务器。 我的服务器中托管了多个域。包括necommerce.online令人毛骨悚然的在内的其他域名都很好。

域:buychino.com

Error:

NET::ERR_CERT_COMMON_NAME_INVALID
Subject: necommerce.online
Issuer: Let's Encrypt Authority X3

我注意到主题产生了不同的领域,似乎我缺少了一些东西。但是我所做的所有配置看起来都不错。

任何帮助将不胜感激。

配置:

server {
    listen [::]:443 ssl http2;
listen 43 ssl http2;


ssl_certificate /etc/letsencrypt/live/buychino.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/buychino.com/privkey.pem;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

server_name buychino.com;

root /home/buychino/public_html;


index index.php

# Redirect 404 errors to prestashop
error_page 404 /index.php?controller=404;

# Gzip Settings, convert all types.
gzip on;
gzip_vary on;
gzip_proxied any;

# Can be enhance to 5, but it can slow you server
# gzip_comp_level    5;
# gzip_min_length    256;

gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;

gzip_disable "MSIE [1-6]\.(?!.*SV1)";

# HSTS (Force clients to interact with your website using HTTPS only)
# For enhanced security, register your site here: https://hstspreload.org/
# WARNING: Don't use this if your site is not fully on HTTPS!
# add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" preload; always;

# Cloudflare / Max CDN fix
location ~* \.(eot|otf|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
}

# Do not save logs for these
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
auth_basic off;
allow all;
log_not_found off;
access_log off;
}

location /admin/ { #Change this to your admin folder
if (!-e $request_filename) {
    rewrite ^/.*$ /admin/index.php last; #Change this to your admin folder
}
}

location / {
# Redirect pretty urls to index.php
try_files $uri $uri/ /index.php?$args;

# Images
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;

# AlphaImageLoader for IE and fancybox
rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;

# Web service API
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

# Installation sandbox
rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
}

# File security
# .htaccess .DS_Store .htpasswd etc
location ~ /\. {
deny all;
}
# Source code directories
location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor)/ {
deny all;
}
# Prevent exposing other sensitive files
location ~ \.(yml|log|tpl|twig|sass)$ {
deny all;
}

# Prevent injection of php files
location /upload {
location ~ \.php$ {
    deny all;
}
}
location /img {
location ~ \.php$ {
    deny all;
}
}

# PHP FPM part
location ~ [^/]\.php(/|$) {
# Verify that the file exists, redirect to index if not
try_files $fastcgi_script_name /index.php$uri&$args;

fastcgi_index  index.php;

# Environment variables for PHP
fastcgi_split_path_info ^(.+\.php)(/.+)$;

include       fastcgi_params;

fastcgi_param PATH_INFO       $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

# [REQUIRED EDIT] Connection to PHP-FPM - choose one
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;

fastcgi_keep_conn on;
fastcgi_read_timeout 30s;
fastcgi_send_timeout 30s;

# In case of long loading or 502 / 504 errors
# fastcgi_buffer_size 256k;
# fastcgi_buffers 256 16k;
# fastcgi_busy_buffers_size 256k;
client_max_body_size 10M;
}
}



server {
    listen [::]:443 ssl http2;
    listen 43 ssl http2;
    ssl_certificate /etc/letsencrypt/live/buychino.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/buychino.com/privkey.pem;

    # ssl_session_timeout 24h;
    # ssl_session_cache shared:SSL:10m;
    # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    # ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:RSA+3DES:AES128-S$
    # ssl_prefer_server_ciphers on;
    # Do not forget to create this file before with OpenSSL : "openssl dhparam $
    # include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    server_name www.buychino.com;
    return 301 https://buychino.com$request_uri;
}



server {
    listen 80;
    listen [::]:80;
    server_name buychino.com www.buychino.com;
    return 301 https://buychino.com$request_uri;
}

1 个答案:

答案 0 :(得分:0)

停止nginx

sudo service nginx stop

删除不正确的证书

sudo rm -rf /etc/letsencrypt/live/buychino.com
sudo rm /etc/letsencrypt/renewal/buychino.com.conf

获取正确的证书

sudo certbot certonly --expand --agree-tos --text --non-interactive --standalone -d buychino.com --email <your_email_for_cert_expiration_alerts>

启动nginx

sudo service nginx start