Adding new nginx server block + issuing Lets Encrypt SSL certificate for it

This guide is useful if you're using HostBill Multi-Brand module on HostBill Enterprise install. This guide assumes you're familiar with linux file editors (like vim or nano).


Replace any occurrence of below with hostname you're adding

  1. Adding new vhost (server block) to nginx:

    Make a copy /etc/nginx/conf.d/main.conf file:

    cp /etc/nginx/conf.d/main.conf /etc/nginx/conf.d/

    Update  server_name block in /etc/nginx/conf.d/ file:

    Contents of /etc/nginx/conf.d/
    include /etc/nginx/upstreams/*.conf;
    server {
        listen 80;
        server_tokens off;
        return 301 https://$host$request_uri;
    server {
        listen 443 ssl;
        server_tokens off;
        charset                     utf-8;
        sendfile                    on;
        tcp_nopush                  on;
        tcp_nodelay                 off;
        reset_timedout_connection   on;
        location ~* ^.+\.(jpg|gif|png|css|js|swf|ico)$ {
            access_log      off;
            log_not_found   off;
            expires         1y;
        include /etc/nginx/ssl.conf;
        include /etc/nginx/locations/*.conf;
  2. Issue a Let's Encrypt certificate using certbot command for your additional brand/domain:

    certbot --nginx -d
  3. Reload nginx to apply new site block + ssl certificate:

    systemctl reload nginx