2017-08-17 4 views
0

Ich habe gerade Gogs auf einem VPS mit Hilfe des Tuto (https://gogs.io/docs/installation/install_from_source) installiert. Ich habe eine Sub-Domain, um meine Gogs-Instanz zu erreichen: git.meinedomainname.com und es funktioniert: http://git.mydomainname.com geht zu meiner Gogs-Instanz mit einem Reverse-Proxy.Aktiviere Letsencrypt in Debian 9 mit Nginx für Gogs

Ich möchte meine Gogs durch SSL geschützt haben, also möchte ich LetsEncrypt mit dem folgenden Tuto (https://certbot.eff.org/#debianstretch-nginx) installieren.

Ich würde gerne sagen, dass ich neu in der Systemadministration bin und nicht unbedingt alles verstehe, was ich während der Installation der Gogs gemacht habe. Ich bin auch neu in Nginx (mehr für Apache).

Hier ist der Prozess, den ich gefolgt:

$ sudo certbot certonly 
Saving debug log to /var/log/letsencrypt/letsencrypt.log 

How would you like to authenticate with the ACME CA? 
------------------------------------------------------------------------------- 
1: Place files in webroot directory (webroot) 
2: Spin up a temporary webserver (standalone) 
------------------------------------------------------------------------------- 
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1 
Please enter in your domain name(s) (comma and/or space separated) (Enter 'c' 
to cancel):git.mydomainname.com 
Obtaining a new certificate 
Performing the following challenges: 
http-01 challenge for git.mydomainname.com 

Select the webroot for git.mydomainname.com: 
------------------------------------------------------------------------------- 
1: Enter a new webroot 
------------------------------------------------------------------------------- 
Press 1 [enter] to confirm the selection (press 'c' to cancel): /home/git/go/src/github.com/gogits/gogs 

** Invalid input ** 
Press 1 [enter] to confirm the selection (press 'c' to cancel): 1 
Input the webroot for git.mydomainname.com: (Enter 'c' to cancel):/home/git/go/src/github.com/gogits/gogs 
Waiting for verification... 
Cleaning up challenges 
Failed authorization procedure. git.mydomainname.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://git.mydomainname.com/.well-known/acme-challenge/N4rMGzoq1Bwyt9MP9fUlVY3_mDnJfRYpQkdvc7WrNJs: "<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: git.mydomainname.com 
    Type: unauthorized 
    Detail: Invalid response from 
    http://git.mydomainname.com/.well-known/acme-challenge/N4rMGzoq1Bwyt9MP9fUlVY3_mDnJfRYpQkdvc7WrNJs: 
    "<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. 

So überprüfte ich den Fehler, den DNS-A-Eintrag ist OK. Ich fand auch einen anderen Tuto in Französisch (https://www.grafikart.fr/formations/serveur-linux/nginx-ssl-letsencrypt), um mir zu helfen, und ich bemerkte, dass ich meine nginx Config für die Website aktualisieren musste, tat ich, obwohl ich einen Reverse Proxy habe (vielleicht ist das Problem hier).

server { 
    listen 80; 
    server_name git.mydomainname.com 

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

    location ~ /\. { 
     deny all; 
     access_log off; 
     log_not_found off; 
    } 

    location/{ 
     proxy_pass http://localhost:port_number; 
    } 
} 

Danke für Ihre Hilfe.

+0

Versuchen Sie '2: Spin einen temporären Webserver (Standalone)' anstelle der Webroot ein. – tkausl

Antwort

0

Sie geben alle Ihre Anfragen an http://localhost:port_number zurück, aber dieses Programm weiß wahrscheinlich nicht, wie man die lets-encrypt-Anfrage behandelt.

Stattdessen sollten Sie Ihre .nun bekannte Position ändern:

location ^~ /.well-known/acme-challenge/ { 
    allow all; 
    root /var/www/letsencrypt; 
} 

Und wenn die certbot sie eine Webroot fragen, können Sie /var/www/letsencrypt

Hinweis beantworten: Sie /var/www/letsencrypt einem ändern Verzeichnis, das Sie möchten. Es muss nur zuerst erstellt werden, und lesbar von Ihrem Nginx-Benutzer