电竞比分网-中国电竞赛事及体育赛事平台

分享

Nginx配置,文件夾權(quán)限和let-encrypt

 印度阿三17 2019-07-02

我試圖在我的Ubuntu 16.0.4服務器上使用certbot and letsencrypt,所以我可以安裝一個郵件服務器.

我正在運行這樣的certbot:

sudo /opt/letsencrypt/certbot-auto certonly –agree-tos –webroot -w
/path/to/www/example -d -d www.

我從certbot獲得以下輸出(下面顯示的代碼段):

   Domain: www.
   Type:   unauthorized
   Detail: Invalid response from
   http://www./.well-known/acme-challenge/QEZwFgUGOJqqXHcLmTmkr5z83dbH3QlrIUk1S3JI_cg:
   "<html>
   <head><title>404 Not Found</title></head>
   <body bgcolor="white">
   <center><h1>404 Not Found</h1></center>
   <hr><center>"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address.

這就是我的目錄結(jié)構(gòu):

root@yourbox:/path/to/www/example$ls -la
total 12
drwxr-xr-x 3 example root    4096 Nov  1 10:17 .
drwxr-xr-x 5 root        webapps 4096 Nov  1 10:13 ..
drwxr-xr-x 2 root        root    4096 Nov  1 10:36 .well-known
root@yourbox:/path/to/www/example$
root@yourbox:/path/to/www/example$cd .well-known/
root@yourbox:/path/to/www/example/.well-known$ls -la
total 8
drwxr-xr-x 2 root        root 4096 Nov  1 10:36 .
drwxr-xr-x 3 example root 4096 Nov  1 10:17 ..
root@yourbox:/path/to/www/example/.well-known$

從上面,我可以看到挑戰(zhàn)文件不存在 – (大概是?)因為,看起來certbot無法寫入文件夾.

但是,我首先需要檢查nginx是否設置正確,并且它是從一個句點開始的文件夾中提供文件.

這是網(wǎng)站的nginx配置文件(/ etc / nginx / sites-available / example):

server {
    # Allow access to the letsencrypt ACME Challenge
    location ~ /\.well-known\/acme-challenge {
        allow all;
    }
}

我手動創(chuàng)建了一個測試文件(sudo touch / path / to / www / example / fake)并給它正確的權(quán)限:

root@yourbox:/path/to/www/example/.well-known/acme-challenge$ls -l
total 0
-rw-r--r-- 1 example webapps 0 Nov  1 10:45 fake

然后我嘗試從瀏覽器訪問http://www./.well-known/acme-challenge/fake – 并得到404錯誤.

這意味著我有兩個錯誤:

>未正確設置Nginx以提供.well-known / acme-challenge文件夾中的文件
> / path / to / www / example文件夾中的文件權(quán)限錯誤,因此certbot無法將其自動生成的文件寫入.well-known / acme-challenge文件夾.

我該如何解決這些問題?

解決方法:

您的Nginx配置文件沒有配置,可以訪問/ path / to / www / example /目錄web.

這是一個簡單的配置,它將使您的網(wǎng)站生效并允許LetsEncyrpt創(chuàng)建有效的證書.請記住80端口需要訪問.

server {
    listen 80;

    server_name www.example.co.uk example.co.uk;

    root /path/to/www/example;

    access_log /var/log/nginx/example.co.uk.log;
    error_log /var/log/nginx/example.co.uk.log;

    index index.html index.htm index.php;

    location ~ /\.well-known\/acme-challenge {
        allow all;
    }

    location / {
        try_files $uri $uri/index.html $uri.html =404;
    }
}

相應地更改server_name,或使用/ etc / hosts文件配置本地域.

來源:https://www./content-3-289351.html

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多