2 Production Nginx config
Kailash Nadh edited this page 2019-07-21 22:19:01 +05:30

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;
    }
}