deploy-with-https.mo
Owner: Sammy Teillet
Control points
If, as an expert of docker, you want to adapt the standard to the context of your project, you have to check that:
Prerequisites
Steps (~15 min)
Install the nginx-proxy companion (~5 min)
Connect to your server
ssh user@your.domainClone the nginx-proxy-companion project on the server at the root of the server.
git clone git@github.com:evertramos/docker-compose-letsencrypt-nginx-proxy-companion.gitCreate a
.envfile
cd docker-compose-letsencrypt-nginx-proxy-companion
cp ./.env.sample .envSet the
NGINX_FILES_PATH=/srv/nginx/datain the.envvim ./.envline 41 replace
NGINX_FILES_PATH=/srv/nginx/data(or a different path if you prefer)
CHECK
Try to launch the companion by running:
./start.shYou should have the following error because the port 80 is already used by your app docker:
ERROR: for nginx-web Cannot start service nginx-web: driver failed programming external connectivity on endpoint nginx-web (4c0105fe57d370c99c0a143c967d1b8737006a4138618e1defebc4bab4e42d11): Bind for 0.0.0.0:80 failed: port is already allocated
Configure your project to use the companion (~5 min)
Remove the binding 80 port command, but expose it
version: '3'
services:
your-web-app: #It should contain port: "80:80"
# ...
- ports:
- - "80:80"
+ expose:
+ - 80Configure the app to use the network created by the companion (
webproxyis the default name)
version: '3'
services:
# ...
+networks:
+ default:
+ external:
+ name: webproxyIn your project set 3 environment variable:
VIRTUAL_HOST,LETSENCRYPT_HOST,LETSENCRYPT_EMAIL. The email will be used by Letsencrypt to notify you if the certificate expire.There are 2 ways:In the docker-compose file
In your prod.env file that is read by your Dockerfile.
In the
./env/prod.envadd the following:
#... other env variable
+ VIRTUAL_HOST=my.domain.cloud.bam.tech
+ LETSENCRYPT_HOST=my.domain.cloud.bam.tech
+ LETSENCRYPT_EMAIL=your@email.comOTHER solution
If you have no .env file you an also Update the docker-compose-prod file
version: '3'
services:
your-web-app: #It should contain port: "80:80"
# ...
environment:
+ - VIRTUAL_HOST=my.domain.cloud.bam.tech
+ - LETSENCRYPT_HOST=my.domain.cloud.bam.tech
+ - LETSENCRYPT_EMAIL=your@email.comMake the switch (~5 min)
BUSINESS INTERRUPTION
You will have to shut down your docker (so the port 80 is available), so during this step your domain won't be accessible.
Cut your app docker:
cd your-project-directory
docker-compose -f docker-compose-prod.yml downStart the companion (go to the companion directory):
cd ../docker-compose-letsencrypt-nginx-proxy-companion
./start.shLaunch your project docker again:
cd -
docker-compose -f docker-compose-prod.yml up -dCHECK
Check the validity of your domain, go to https://your.domain
Go there and check your domain. Useful tip: go to the Handshake Simulation section and check the supported devices.
Last updated