others-how to put prometheus alertmanager behind a reverse-proxy like nginx?

1. Purpose

In this post, I will show you how to put a prometheus alertmanager behind a reverse-proxy like nginx.

When we start an alertmanager as follows:

./alertmanager-0.24.0.linux-amd64/alertmanager  --web.external-url=http://mydomain.com/alertmanager --config.file=./alertmanager.yml --cluster.listen-address= 

What is web.external-url:

--web.external-url=WEB.EXTERNAL-URL

URL of an externally accessible Alertmanager (e.g. Alertmanager is reverse proxyed through nginx)



2. Solution

nginx.conf:

    server {
        listen       80;
        server_name  localhost;
        root         /usr/share/nginx/html;


        location /alertmanager/ {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;

                proxy_pass http://127.0.0.1:9093/alertmanager/;
        }
    }



3. Summary

In this post, I demonstrated how to put the alertmanager behind a nginx . That’s it, thanks for your reading.