Skip to content

Instantly share code, notes, and snippets.

View nuxwin's full-sized avatar
🎯
Focusing

Laurent Declercq nuxwin

🎯
Focusing
View GitHub Profile
@nuxwin
nuxwin / README.md
Created April 12, 2016 22:51 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
#!/usr/bin/env php
<?php
/*
Copyright 2013 Stuart Carnie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
upstream foo_app {
server 127.0.0.1:3000;
}
server {
listen 80;
# listen [::]:80 default_server ipv6only=on;
root /home/user/foo/foo_web/public;
vendor
composer.lock