2017-02-14 47 views
0

我有一個網站eg。 domain.net ,並在我的nginx/centos服務器上成功運行certbot/letsencrypt安裝。使用proxy_pass會影響letsencrypt的安裝嗎?

該域的安全,看起來不錯。現在我已經添加了一個幽靈博客到我想加密的網站,例如。 blog.domain.net。

此博客設置在與原始網站不同的根文件夾中,但設置在相同的服務器上。我在2000上使用proxy_pass來設置子域。

現在我已經改變了唯一的事情是我我的網站,提供的nginx中添加

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

到blog.domain.net.conf文件。 我也試圖與無濟於事:(

每當我每運行安裝說明certbot,它輸出這個錯誤添加此到conf.d/domain.net.conf文件中。

Failed authorization procedure. blog.domain.net (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://blog.domain.net/.well-known/acme-challenge/FVQmSHuCmeiOObPDOCiD2OFP8Ivvst5n2ZwIZoeXGU8: "<html> 
<head><title>404 Not Found</title></head> 
<body bgcolor="white"> 
<center><h1>404 Not Found</h1></center> 
<hr><center>" 

IMPORTANT NOTES: 
- The following errors were reported by the server: 

    Domain: blog.domain.net 
    Type: unauthorized 
    Detail: Invalid response from 
    http://blog.domain.net/.well-known/acme-challenge/FVQmSHuCmeiOObPDOCiD2OFP8Ivvst5n2ZwIZoeXGU8: 
    "<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. 

任何幫助,非常感謝!

謝謝

  • 編輯*

內內conf.d網站可用/ blog.domain.net.conf

server { 
    listen  80; 
    server_name blog.domain.net www.blog.domain.net; 

    # note that these lines are originally from the "location /" block 
    root /var/www/blog.domain.net/html; 
    index index.php index.html index.htm; 

    location/{ 
     try_files $uri $uri/ =404; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header HOST $http_host; 
     proxy_set_header X-NginX-Proxy true; 
     proxy_pass http://127.0.0.1:2000; 
     proxy_redirect off; 
    } 

    error_page 404 /404.html; 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/html; 
    } 

    location ~ \.php$ { 
     try_files $uri =404; 
     fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include fastcgi_params; 
    } 
} 

代碼代碼/ blog.domain.net.conf

# upstream ghost { 
# server 127.0.0.1:2000; 
# } 

server { 
    listen  80; 
    server_name blog.domain.net; 

    access_log /var/log/nginx/ghost.access.log; 
    error_log /var/log/nginx/ghost.error.log; 

    proxy_buffers 16 64k; 
    proxy_buffer_size 128k; 

    location ~ /.well-known { 
     /var/www/blog.domain.net/html; 
    } 

location/{ 
     proxy_pass http://127.0.0.1:2000; 
     proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 
     proxy_redirect off; 

     proxy_set_header Host   $host; 
     proxy_set_header X-Real-IP  $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Proto https; 
    } 

} 

回答

1

我認爲你正在運行Letsencrypt安裝使用--web-root選項,如果是這樣,請將web根目錄設置爲/var/www/html/或放置HTML內容的路徑;然後

location ~ /.well-known { 
    root /var/www/html; 
} 

這個位置塊應該放在所有其他類似location /在那裏你可以指定proxy_pass選項上面,我已經回答了letsencrypt問題here,是隨安裝命令來檢查。

+0

嗨@ sideeffect0! 感謝您的幫助!我試過你的建議,不幸的是它似乎沒有改變任何東西:( 我已經發布了一個編輯我的問題與代理傳遞的代碼在nginx/sites-available目錄以及nginx/conf.d目錄 – user3648969

+0

首先'站點啓用'目錄用於處理活動nginx配置,運行nginx重新加載,並且還評論你如何運行let'sencrypt安裝程序 –

+0

這不是'網站啓用',而是'站點可用'文件夾,雖然我猜他們是鏈接/鏈接的權利 反正,我運行sudo nginx -t,它給了我'/var/www/blog.domain.net/html「/etc/nginx/conf.d中的未知指令/blog.domain.net.conf' – user3648969

相關問題