Install MailHog with Nginx on Ubuntu server

Debian / Ubuntu

sudo apt-get -y install golang-go
go get

Then, start MailHog by running /path/to/MailHog in the command line.

E.g. the path to Go’s bin files on Ubuntu is ~/go/bin/, so to start the MailHog run:


sudo nano /etc/systemd/system/mailhog.service

Description=MailHog service



sudo systemctl enable mailhog

sudo systemctl start mailhog

Add it to nginx

sudo nano /etc/nginx/sites-available/default

server {
        server_name mail.your.domain;
        listen 80;
        listen [::]:80;

        location / {
                proxy_pass      http://localhost:8025;
                proxy_set_header    Host             $host;
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_http_version 1.1;
                proxy_redirect off;
                proxy_buffering off;

sudo nginx -t

sudo service nginx reload

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.