Skip to content

Production Nginx config

Kailash Nadh edited this page Jul 21, 2019 · 2 revisions

Since listmonk does not have built in user auth yet, it's best to put listmonk behind a proxy like Nginx and setup basicauth on all endpoints except for the few endpoints that need to be public. Here is a sample config for using listmonk in production.

upstream listmonk {
	server localhost:9000;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name listmonk.yoursite.com;

    ssl_certificate /your/ssl/cert.cert;
    ssl_certificate_key /your/ssl/cert.key;

    root /home/listmonk;

    location / {
        # Protect all routes by default with basicauth.
        auth_basic "Admin";
        auth_basic_user_file /your/httpasswd;

        proxy_pass http://listmonk;
    }

    # Public endpoints that should not be behind auth.
    location /subscription {
        proxy_pass http://listmonk;
    }

    location /link {
        proxy_pass http://listmonk;
    }

    location /uploads {
        include  /etc/nginx/mime.types;
        root /home/listmonk;
        gzip_static on;
    }

    location /public {
        proxy_pass http://listmonk;
        gzip_static on;
    }

    location ~ /campaign/(.+?).png {
    	# Tracking pixel.
        proxy_pass http://listmonk;
    }
}
You can’t perform that action at this time.