How do we configure prometheus with nginx proxy and gitlab oauth

I have setup gitlab server with prometheus and grafana.

Grafana can be access using https://servername/-/grafana and it is asking gitlab oauth when accessing.

i am able to access prometheus only on localhost as we have configured with localhost option for security reason.

I would like to setup prometheus in same way with oauth like grafana.


I tried nginx proxy for this.

Added bellow config in /etc/gitlab/gitlab.rb to start prometheus service with web.external-url option

Custom Prometheus flags

prometheus[‘flags’] = {
‘storage.tsdb.path’ => “/var/opt/gitlab/prometheus/data”,
‘storage.tsdb.retention.time’ => “15d”,
‘config.file’ => “/var/opt/gitlab/prometheus/prometheus.yml”,
‘web.external-url’ => “https://localhost/-/prometheus/”,
‘web.route-prefix’ => “/”

Also added nginx proxy.

nginx[‘custom_gitlab_server_config’] = “location /-/prometheus/ {\n proxy_pass http://localhost:9090/; \n}\n”

with this config changes I am able to access https://servername/-/prometheus/

But I need this to be integrated with gitlab outh…

when I tried to add auth_request directive in nginx for outh2 nginx error logs says this directive not supported due to nginx is build without --with-http_auth_request_module module in gitlab.

/opt/gitlab/embedded/sbin/nginx -V

nginx version: nginx/1.16.1
TLS SNI support enabled
configure arguments: --prefix=/opt/gitlab/embedded --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_v2_module --with-http_realip_module --with-http_sub_module --with-ipv6 --with-debug --add-module=/var/cache/omnibus/src/nginx-module-vts --with-ld-opt=-L/opt/gitlab/embedded/lib --with-cc-opt=’-L/opt/gitlab/embedded/lib -I/opt/gitlab/embedded/include’

I don’t see how we can configure prometheus with gitlab auth.

Please suggest…