Promtail nginx basic auth

I install promtail binary and it works.

The promtail is hosted on a different server from loki server.

I don’t think promtail has authentication built-in. So the idea is to use nginx basic auth.

The problem is I am unable to do so.

When I use the follow settings, journalctl -xe returns (98: Address already in use)

server {
    listen 9080;

    location / {
        auth_basic "Authorization required";
        auth_basic_user_file /etc/nginx/conf.d/.htpasswd;

Please share how I can make it work. If this can’t be done by nginx, please share how you do it :grin:


Hi @shawnngtq,

The error probably means that there is already some process listening on the port 9080.
You can either find what it is or you can try to use a different port.
See this stackoverflow discussion about the similar question :wink:


@findmyname , I know, it’s running promtail. I want nginx basic auth before loading the promtail page

@shawnngtq , Promtail does support basic_auth in the clients seciton

This is my config

          - url: ${LOKI_URL}
              username: ${LOKI_BASIC_AUTH_USER}
              password: ${LOKI_BASIC_AUTH_PW}
              cluster: ${K8S_CLUSTER}

@b0b , I want to hide the promtail behind nginx basic auth.

The same way we config for Loki. But I do not see such an option …

Ok, sorry, I misunderstood.

no worries :grin:

I feel that it can’t be done. Unless promtail add this basic auth so that it works exactly like prometheus’s node exporter.

Hoping someone here has done it

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.