Setup an Nginx server with SSL in one command line

Setup an Nginx server with SSL in one command line

Recently, due to the need for multiple servers/domain management personally, I feel waste of time to config the server one by one. Especially, when server restart, migration, upgrade, SSL certificate update.

Thus, I have made a Github project to accomplish this task automatically. This project has the following advantages

  • Almost zero dependence: all you need is docker. It even does not require any reversed proxy server like Nginx, Apache (httpd) installed.
  • Simple usage: all operations are accomplished in just ONE command with ZERO argument. Everything is done underneath.
  • Secured and high performance: the default configuration is built based on h5bp configuration.
  • High customizable: you can configure Nginx as you like without touching the bash script or docker image.
  • Versatile: support multiple domains in the same server, automatic SSL refresh, automatic restart Nginx server if SSH certification is updated.
  • Open-source
  • Slack webhook notification if there is an error when refreshing the SSL certificate.


  • Make sure there is no process listening to port 80 or 443 via sudo netstat -tulnp or more precise with
sudo netstat -tulnp | grep :80
sudo netstat -tulnp | grep :443
  • Change the DNS setting in your domain provider control panel to point to your server. This step is required to verify the SSL certificate
  • Download the project from github repository
git clone
  • Go to the project directory cd ssl
  • Setup your domain and listening port
cp .env.example .env
# edit .env
cat .env

The environment file is as below with are domain names, 8082 8081 are local listening port, respectively.
SLACK_WEBHOOOK_URL is a slack webhook URL to send an error if there is when refreshing an SSL certificate. If this variable is empty, the error will be printed locally only without sending it to the slack channel.,
#slack webhook can be empty

  • Now, execute ./ to start/restart the Nginx server
  • To automatically check for SSL certificate update and server restart, add the following crontab via crontab -e
0 15 * * * $HOME/ssl/


In addition, to customize Nginx configuration. You need to do all steps above. Then, there will be a file named nginx.conf in build/ directory. Copy this file to the root directory of the project cp build/nginx.conf ..

Modify ./nginx.conf with your own customization, then re-run ./ From now on customized configuration will be used to restart the Nginx server instead of the default.

How to stop the server

Run ./ stop to stop the running server.

Happy coding!

xem tiếng việt