2017-08-17 1 views
0

Je viens d'installer Gogs sur un VPS à l'aide du tuto (https://gogs.io/docs/installation/install_from_source). J'ai un sous-domaine pour atteindre mon instance de gogs: git.mondomaine.com et cela fonctionne: http://git.mydomainname.com va à mon instance gogs avec un proxy inverse. Je voudrais que mes gogs soient protégés par SSL, donc je voudrais installer LetsEncrypt en utilisant le tuto suivant (https://certbot.eff.org/#debianstretch-nginx).Activer Letsencrypt dans Debian 9 avec Nginx pour Gogs

Je voudrais dire que je suis nouveau dans l'administration système et que je ne comprends pas nécessairement tout ce que j'ai fait pendant l'installation de Gogs. Je suis aussi nouveau à Nginx (plus habitué à Apache).

Voici le processus que je suivais:

$ 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. 

Alors j'ai vérifié l'erreur, le DNS Un enregistrement est OK. J'ai aussi trouvé un autre tuto en français (https://www.grafikart.fr/formations/serveur-linux/nginx-ssl-letsencrypt) pour m'aider et j'ai remarqué que je devais mettre à jour ma configuration nginx pour le site, je l'ai fait, malgré un proxy inverse (peut-être que le problème est ici).

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; 
    } 
} 

Merci pour votre aide.

+0

Essayez '2: Lancez un serveur web temporaire (autonome) au lieu du serveur Web. – tkausl

Répondre

0

Vous demandez toutes vos demandes à http://localhost:port_number, mais ce programme ne sait probablement pas comment gérer la demande lets-encrypt.

Au lieu de cela, vous devriez changer votre emplacement connu .bien à:

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

Et quand le certbot vous demandez un Webroot, vous pouvez répondre /var/www/letsencrypt

Note: vous pouvez changer à tout /var/www/letsencrypt répertoire que vous voulez. Il suffit de le créer en premier et de le lire par l'utilisateur de votre nginx.