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:

Thanks!

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:

BR

@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

        clients:
          - url: ${LOKI_URL}
            basic_auth:
              username: ${LOKI_BASIC_AUTH_USER}
              password: ${LOKI_BASIC_AUTH_PW}
            external_labels:
              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