Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow relative URL in web.external-url #1583
Comments
brian-brazil
added
the
question
label
Apr 24, 2016
This comment has been minimized.
This comment has been minimized.
|
That field expects an absolute URL. The highlighted sentence means if that parameter is not set at all, a default will be chosen, which uses Is it not an option to use |
This comment has been minimized.
This comment has been minimized.
chancez
commented
Apr 26, 2016
|
I'm running into this myself because I'm running prometheus in Kubernetes and attempting to access it locally via My main issue is that I need to be able to specify the prefix so this doesn't happen when I try to access it via chrome:
|
This comment has been minimized.
This comment has been minimized.
|
I have added the hostname (and implicitly port), and it works fine, though I do have to make sure to omit it when I'm running locally, which is a bit of a pain (because the port is different behind the proxy). I guess this is perhaps a feature request to revert to the behaviour (unexpectedly?) permitted in 0.16. |
grobie
added
the
feature-request
label
Apr 27, 2016
grobie
changed the title
Is web.external-url allowed to be a relative URL?
Allow relative URL in web.external-url
Apr 27, 2016
This comment has been minimized.
This comment has been minimized.
|
I'm open for allowing relative URLs as well. |
fabxc
added
kind/question
kind/enhancement
and removed
question
labels
Apr 28, 2016
This comment has been minimized.
This comment has been minimized.
aaskey
commented
Jan 26, 2017
•
|
Set both web.external-url and web.route-prefix will work. Below is my config:
|
This comment has been minimized.
This comment has been minimized.
tylux
commented
Feb 23, 2017
|
@chancez I know this is old but did you figure out the issue of /graph not loading correctly with that 404 error? |
This comment has been minimized.
This comment has been minimized.
thenayr
commented
Feb 23, 2017
•
|
@tylux It won't. If you are accessing it through Kubernetes my best advice is to run |
This comment has been minimized.
This comment has been minimized.
tylux
commented
Feb 23, 2017
|
this particular instance is not inside Kubernetes, it is a standalone Prometheus box that is being proxy_passed from a Nginx box been using the following snippet from #2193 and it mostly works other than that 404 on "static/js/graph_template.handlebar?_=1461656431100" resource on the /graphs page.
|
grobie
removed
the
kind/question
label
Mar 5, 2017
This comment has been minimized.
This comment has been minimized.
|
Can we maybe be a bit smarter about figuring out the web root ourselves? |
This comment has been minimized.
This comment has been minimized.
montanaflynn
commented
Jun 30, 2017
|
We are also trying to set up a portal to prometheus web UI from behind an nginx reverse proxy. Where do we set the config? I couldn't find any examples of setting these fields in the docs.
|
This comment has been minimized.
This comment has been minimized.
linusguan
commented
Jul 2, 2017
|
@montanaflynn You set them as arguments when you run Prometheus, if you get it to work, do you mind sharing your settings? |
This comment has been minimized.
This comment has been minimized.
|
I can't figure out how this is suppose to work either. I'm using the kubernetes api proxy and if I don't set external-url, it can't load the js files for /graph. If I set it to something (and break alternative ways to access this), that gets added additionally to the path prefix in the request. Unless I miss something, I believe external-url isn't doing what was intended. I believe we could make this work for 90% of users without rewriting requests or flags in prometheus. From what I can tell, something in prometheus is already using the request path to figure out url prefixes. This is /graph snippet without external-url set:
As you see, the path are prefixed properly, this is why without setting anything, everything except the graph ui works. There I get this error: Now setting The only thing I need to figure out to fix this is how the correct prefixing works.. I'm pretty surprised and have no idea yet.. |
This comment has been minimized.
This comment has been minimized.
|
Hope not the k8s apiserver proxy is doing this? |
This comment has been minimized.
This comment has been minimized.
linusguan
commented
Jul 4, 2017
•
|
@discordianfish I think even if you set the correct prefix by setting see here: #2193 |
discordianfish
referenced this issue
Jul 5, 2017
Closed
when -web.route-prefix is set, resource and nav links are not prefixed #2193
This comment has been minimized.
This comment has been minimized.
|
@discordianfish oh yea, kube API server proxy fiddles around with your HTML IIRC. |
This comment has been minimized.
This comment has been minimized.
|
That would explain all my and probably lot of other people' confusion. If it's really that and nothing on the prometheus side, it's impossible to fix this without introducing yet another flag which only sets a prefix for things we load in js.. |
This comment has been minimized.
This comment has been minimized.
thenayr
commented
Jul 5, 2017
•
|
No, this isn't the Kube Proxy fault. Other software handles this perfectly fine (see Grafana/Kibana etc.) |
This comment has been minimized.
This comment has been minimized.
|
@thenayr Do you know how this is suppose to work? We might lack some understanding how web applications handle this in general. I've opened kubernetes/kubernetes#48503 to clarify the apiserver proxy's behavior. |
This comment has been minimized.
This comment has been minimized.
thenayr
commented
Jul 10, 2017
•
|
@discordianfish I would model after what Kibana does for A few references: 1 - kibana docs In the 2nd/3rd links you can see how Kubernetes logging addon only specifies the base path as |
This comment has been minimized.
This comment has been minimized.
|
This looks pretty much like what external-url is doing, no? If I set that, I get the prefix twice. Once due the prefixing and then something else (kube api's proxy or something in the 'middleware'). Either way, I still don't understand what is prefixing the URLs in the prometheus html when external-url is not set. |
This comment has been minimized.
This comment has been minimized.
thenayr
commented
Jul 10, 2017
•
|
Here's one example of where a script is being loaded over absolute path instead of external-url: This is pulled in via ajax here This particular piece causes the graph page to not load properly. |
This comment has been minimized.
This comment has been minimized.
|
I know, as I said: We can fix that by setting the prefix path, but that also prefixes the HTML. In this specific case we would need to prefix the ajax stuff but not the HTML. But first we need to understand what is going on here and I don't have time for that deep dive right now. I've opened kubernetes/kubernetes#48503 and hope to get some clarification on the proxy behavior. |
This comment has been minimized.
This comment has been minimized.
thenayr
commented
Jul 10, 2017
•
|
Understood. Dug a bit into the k8s proxy code and it looks like the following happens: URL's that aren't "proxy aware" aka don't include the k8s proxy path (/api/v1/proxy...) in them will be rewritten to include them, as seen here URL's that already include the proxy path are deemed "proxy aware" and will not be rewritten as seen here I believe this would explain the current behavior of Prometheus going through kube-proxy with an The proxy looks for relative links that don't reference the proxy path, in the case of prometheus it is getting absolute URL's throughout, so it will rewrite them again to include the proxy path (but the ajax links work fine because those aren't rewritten). |
This comment has been minimized.
This comment has been minimized.
|
External URL is what is used to render links in the HTML (not exclusively, but for the purpose of this explanation). And route prefix sets the routes the actual http routes are registered to which for the better or worse defaults to the path of the configured external URL (I've proposed to change this, but we decided not to). As the kube proxy strips the prefix of /v1/proxy/.../graph the request ends up being /graph. If I understand the problem correctly solution here is that you need to set external URL to the full proxy URL and route prefix to just "/" as described above. This is solved in the new alertmanager UI, but applying the same method would cause breaking changes to the Prometheus UI if we introduce it in the same way in the same way as the new Alertmanager UI does it. We'll probably only be able to solve this confusion once we rewrite the Prometheus UI in the same way. |
This comment has been minimized.
This comment has been minimized.
|
As @thenayr figured out, all we need to do is support relative URLs. The apiserver proxy will detect them as already prefixed and leave them alone. |
discordianfish
referenced this issue
Jul 14, 2017
Closed
Allow web.external-url to be relative #2948
brian-brazil
added
priority/P2
component/ui
labels
Jul 14, 2017
This comment has been minimized.
This comment has been minimized.
|
FWIW I've been able to setup (after a lot of efforts) something pretty decent. Network flow :
prometheus-company-com-oauth2-proxy deployment :
ingress prometheus-company-com-oauth2-proxy
oauth2_proxy conf (interesting bits):
nginx reverse proxy conf:
Hope it helps. Cheers. |
This comment has been minimized.
This comment has been minimized.
aduzsardi
commented
Apr 23, 2018
|
It's working like this without any issues
Nginx config
Hopefully this helps somebody :) |
This comment has been minimized.
This comment has been minimized.
RKdev
commented
May 8, 2018
•
This comment has been minimized.
This comment has been minimized.
rafaelmagu
commented
Jun 8, 2018
•
|
I'm not sure if it's entirely related, but if I don't provide |
This comment has been minimized.
This comment has been minimized.
rafaelmagu
commented
Jun 8, 2018
|
To better illustrate my comment, I have HAproxy on a bastion, with path-based routing for different backend services. For Prometheus, any request starting with The source for If I add Note: by Alertmanager does not present this behaviour at all. Setting only (I realise Alertmanager is more of a single page app, so this would not be an issue anyway) |
This comment has been minimized.
This comment has been minimized.
rafaelmagu
commented
Jun 8, 2018
•
|
With |
This comment has been minimized.
This comment has been minimized.
deveshmehta
commented
Jun 8, 2018
•
|
Thanks Rafael for the details. In my case the culprit is the recently added Kibana entry in the NGINX config which has a location /api which is conflicting with prometheus/api. Will you be able to suggest the any solution/best practice to handle this. |



malcolmr commentedApr 24, 2016
I'm serving Prometheus behind a reverse-proxy under a
/prometheuspath, so in 0.16, I'd setweb.external-urlto/prometheus.0.18 complains about that:
Is it intended that
web.external-urlmust be an absolute URL? (As/foois a valid path-absolute relative URL.)The help reads: "The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically."
It seems like either the validation is too strict, or that last sentence is (now) incorrect.