3. Nginx virtual host config
Create a new virtual host configuration file
$ sudo nano /etc/nginx/sites-available/emailengine.conf
And paste the following configuration. Make sure to change the domain name and verify that EmailEngine's HTTP port would be the correct one (defaults to 3000):
server {
listen 80;
listen 443 ssl http2;
server_name example.com; # <- change this domain name
ssl_certificate_key /etc/ssl/private/emailengine-privkey.pem;
ssl_certificate /etc/ssl/certs/emailengine-fullchain.pem;
location / {
client_max_body_size 50M;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3000; # <- use EmailEngine's HTTP port
}
# Enforce HTTPS
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
Next, we would have to enable the configuration.
sudo ln -s /etc/nginx/sites-available/emailengine.conf /etc/nginx/sites-enabled/emailengine.conf
Also, verify that the Nginx configuration does not include any errors. Otherwise, reloading or restarting it would stop the Nginx service.
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
And finally, apply the new config.
$ sudo systemctl reload nginx
At this point, if you'd open the domain name in your browser, it should show you EmailEngine's page. Except you are still using the dummy HTTPS certificates, so in most cases, you'd see the invalid certificate warning instead.