Issues with Grafana on selfhosted instance behind ReverseProxy
I am running Gitlab behind a reverse proxy. Unfortunately Grafana doesn't work with the Apache2 configuration in this repo.
I have a simplified version of both the http and https configurations:
Configuration port 80
<VirtualHost *:80>
ServerName gitlab.domain.com
ServerSignature Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Location />
Require all granted
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://domain.com/
</Location>
RewriteEngine on
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
RewriteCond %{SERVER_NAME} =gitlab.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Configuration port 443:
<IfModule mod_ssl.c>
SSLStaplingCache shmcb:/var/run/apache2/stapling_cache(128000)
<VirtualHost *:443>
ServerName gitlab.domain.com
ServerSignature Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Location />
Require all granted
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://domain.com/
</Location>
RequestHeader set Host "gitlab.domain.com"
RequestHeader add X-Forwarded-Ssl on
RequestHeader set X-Forwarded-Proto "https"
RewriteEngine on
#Forward all requests to gitlab-workhorse except existing files like error documents
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
</VirtualHost>
</IfModule>
I have tried adding these Location blocks (interchangeably):
<Location /-/grafana>
ProxyPass http://127.0.0.1:3000
ProxyPassReverse http://127.0.0.1:3000
</Location>
and
<Location /-/grafana>
ProxyPassReverse http://127.0.0.1:3000/
</Location>
Unfortunately I am still stuck with a 404 error page.
For more info check my issue submitted in the omnibus-gitlab repo: Here