issue126:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue126:c_c [2017/11/06 18:34] – d52fr | issue126:c_c [2017/11/09 15:31] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
**As the web moves towards a “secure by default” approach, enabling HTTPS on your website is becoming more and more important. I’ve spent the last few weeks updating the websites I manage to run HTTPS, including some that run in docker. As some readers may have noticed, I have also switched the fullcirclemagazine.org website over to HTTPS. The reason for this is simple - Google (and others) are encouraging the use of HTTPS by clearly denoting (with a green padlock) encryption on websites. This month’s article will therefore be dedicated to what HTTPS is, how to get set up with Let’s Encrypt, and how to combine it with docker.** | **As the web moves towards a “secure by default” approach, enabling HTTPS on your website is becoming more and more important. I’ve spent the last few weeks updating the websites I manage to run HTTPS, including some that run in docker. As some readers may have noticed, I have also switched the fullcirclemagazine.org website over to HTTPS. The reason for this is simple - Google (and others) are encouraging the use of HTTPS by clearly denoting (with a green padlock) encryption on websites. This month’s article will therefore be dedicated to what HTTPS is, how to get set up with Let’s Encrypt, and how to combine it with docker.** | ||
+ | |||
+ | Comme le Web évolue vers une approche « sécurisée par défaut », l' | ||
**What is HTTPS and Let’s Encrypt? | **What is HTTPS and Let’s Encrypt? | ||
Ligne 6: | Ligne 8: | ||
That changed recently with Let’s Encrypt, which will create secure, trusted certificates for free. The main difference between paid certificates and free ones through Let’s Encrypt are the duration. Certificates from Let’s Encrypt expire after 90 days - meaning you need to actively renew them more often than paid certificates. However, this can be done with a helper tool (I use ‘certbot’), | That changed recently with Let’s Encrypt, which will create secure, trusted certificates for free. The main difference between paid certificates and free ones through Let’s Encrypt are the duration. Certificates from Let’s Encrypt expire after 90 days - meaning you need to actively renew them more often than paid certificates. However, this can be done with a helper tool (I use ‘certbot’), | ||
+ | |||
+ | Qu' | ||
+ | |||
+ | HTTPS aide à protéger les données privées quand on s' | ||
+ | |||
+ | Ça a changé récemment avec Let's Encrypt, qui crée des certificats sûrs et fiables gratuitement. La principale différence entre les certificats payants et ceux gratuits par l' | ||
**What is Docker? | **What is Docker? | ||
Docker is a system for running services in virtual containers - and is built upon the existing Linux kernel. This means that it is faster, and requires less disk and RAM space than full virtualized environments (such as Vagrant). You can use it to run any number of systems, and multiple containers can communicate with each other via a private network.** | Docker is a system for running services in virtual containers - and is built upon the existing Linux kernel. This means that it is faster, and requires less disk and RAM space than full virtualized environments (such as Vagrant). You can use it to run any number of systems, and multiple containers can communicate with each other via a private network.** | ||
+ | |||
+ | qu' | ||
+ | |||
+ | Docker est un système pour faire tourner des services dans des conteneurs virtuels, et il est construit sur le noyau Linux existant, ce qui signifie qu'il est plus rapide et qu'il demande moins d' | ||
**Prerequisites | **Prerequisites | ||
Ligne 16: | Ligne 28: | ||
Nginx-proxy is an image that automatically directs and manages the traffic to various other containers (so the URLs lead to the correct container).** | Nginx-proxy is an image that automatically directs and manages the traffic to various other containers (so the URLs lead to the correct container).** | ||
+ | |||
+ | Prérequis | ||
+ | |||
+ | Dans mon cas, les services avec lesquels je travaillais couvraient 3 conteneurs. L'un faisait tourner une image de nginx-proxy de jwilder, un autre, une image d'un nginx de base et un autre, une image d'un apache de base. Les images de base de nginx et apache étaient liées entre elles sous forme de serveur LEAMP (un serveur Apache derrière un serveur Nginx, où Nginx s' | ||
+ | |||
+ | Nginx-proxy est une image qui dirige et gère automatiquement le trafic vers divers autres conteneurs (de sorte que les URL conduisent vers le bon conteneur). | ||
Ligne 23: | Ligne 41: | ||
Fortunately, | Fortunately, | ||
+ | |||
+ | Par où commencer ? | ||
+ | |||
+ | Ma première recherche ne m'a pas donné trop de messages sur ce sujet précis. Il y en avait plein sur le paramétrage de nginx et apache pour desservir des sites HTTPS. Cependant, la complication vient de l' | ||
+ | |||
+ | Heureusement, | ||
**Create Certificate | **Create Certificate | ||
Ligne 33: | Ligne 57: | ||
Then answer the questions (you will need to point it to the actual webroot of your website that is publically accessible, otherwise Let’s Encrypt cannot confirm you own the domain and the certificate is not created). Once the certificate is created, it will be stored in / | Then answer the questions (you will need to point it to the actual webroot of your website that is publically accessible, otherwise Let’s Encrypt cannot confirm you own the domain and the certificate is not created). Once the certificate is created, it will be stored in / | ||
+ | |||
+ | Créer un certificat | ||
+ | |||
+ | Pour ce faire, vous devez installer certbot, ce qui dépend de l'OS de votre serveur et de sa version. Pour la plupart des versions d' | ||
+ | |||
+ | Une fois certbot installé, vous pourrez créer votre certificat. Je l'ai fait en utilisant la commande certonly, car je ne veux pas que certbot tente d' | ||
+ | |||
+ | certbot certonly | ||
+ | |||
+ | Puis répondez aux questions (vous aurez besoin de le faire pointer sur la vraie racine de votre site Web qui est accessible publiquement, | ||
**Create folder for docker volume | **Create folder for docker volume | ||
Ligne 45: | Ligne 79: | ||
If you want nginx-proxy to automatically apply the certificates, | If you want nginx-proxy to automatically apply the certificates, | ||
+ | |||
+ | Créer un dossier pour le volume docker | ||
+ | |||
+ | Alors que vous pouvez relier le dossier de letsencrypt à docker, je vous recommanderais de créer un nouveau dossier auquel vous pourrez facilement accéder (dans votre répertoire home, par exemple). | ||
+ | |||
+ | Une commande qui fonctionne pour cela serait : | ||
+ | |||
+ | mkdir -p ~/ | ||
+ | |||
+ | cp / | ||
+ | |||
+ | Si vous voulez que nginx-proxy utilise automatiquement les certificats, | ||
**Link Certificate to Nginx-Proxy | **Link Certificate to Nginx-Proxy | ||
Ligne 57: | Ligne 103: | ||
For ease of use and managing the variables, I’d recommend using docker-compose, | For ease of use and managing the variables, I’d recommend using docker-compose, | ||
+ | |||
+ | Relier le certificat à Nginx-proxy | ||
+ | |||
+ | Pour fournir les certificats à une image, vous pouvez utiliser la commande suivante (prise sur le site officiel de nginx-proxy) : | ||
+ | |||
+ | docker run -d -p 80:80 -p 443:443 -v / | ||
+ | |||
+ | Remplacez / | ||
+ | |||
+ | Si vous préférez avoir plus de contrôle (ou si vous avez un seul certificat pour plusieurs domaines), vous pouvez, à la place, paramétrer la variable CERT_NAME dans l' | ||
+ | |||
+ | Pour une utilisation et une gestion facilitée des variables, je recommanderais l' | ||
**Possible issues | **Possible issues | ||
I ran into an issue where I had mistakenly linked the cert file in place of the private key, which resulted in nginx -s reload failing on nginx-proxy. There were no obvious errors, but it resulted in the port 443 being closed, and the connection being refused. So if nginx-proxy isn’t working properly for you, make sure you are linking the correct folder, and have read/write permissions; | I ran into an issue where I had mistakenly linked the cert file in place of the private key, which resulted in nginx -s reload failing on nginx-proxy. There were no obvious errors, but it resulted in the port 443 being closed, and the connection being refused. So if nginx-proxy isn’t working properly for you, make sure you are linking the correct folder, and have read/write permissions; | ||
+ | |||
+ | Problèmes possibles | ||
+ | |||
+ | J'ai rencontré un problème quand j'ai relié par erreur le fichier cert au lieu de la clé privée, ce qui a entraîné le non-fonctionnement de nginx -s reload sur nginx-proxy. Il n'y avait pas d' | ||
**Where can I find more information on Docker? | **Where can I find more information on Docker? | ||
Ligne 67: | Ligne 129: | ||
I hope this article proves useful for anyone who, like me, was making the process much more complicated than necessary, or was running into a similar issue as I did. If you have any questions, comments, or article suggestions, | I hope this article proves useful for anyone who, like me, was making the process much more complicated than necessary, or was running into a similar issue as I did. If you have any questions, comments, or article suggestions, | ||
+ | |||
+ | Où puis-je trouver plus d' | ||
+ | |||
+ | Les pages hub de Docker pour les différentes images vous disent typiquement comment les configurer. Si vous lisez la page de documentation de docker-compose, | ||
+ | |||
+ | J' | ||
+ |
issue126/c_c.1509989664.txt.gz · Dernière modification : 2017/11/06 18:34 de d52fr