Access Via Ingress
infinitydon opened this issue · 6 comments
Hi,
Is there an option to configure the deployment to use a parameter like baseURL?
I am trying to access this via an Nginx ingress, I could only get the homepage working but the remaining links are breaking (/raw, /metrics). With the baseURL, all calls will be appended to it.
My ingress config that I used:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: goldpinger
namespace: kube-system
annotations:
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubernetes.io/auth-realm: "Authentication Required"
nginx.ingress.kubernetes.io/service-upstream: "true"
nginx.ingress.kubernetes.io/upstream-fail-timeout: "30"
nginx.ingress.kubernetes.io/limit-connections: "500"
nginx.ingress.kubernetes.io/limit-rpm: "500"
nginx.ingress.kubernetes.io/limit-rps: "50"
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: "nginx"
spec:
tls:
rules:
- host: xxx.xx.xxx
http:
paths:
- path: /goldpinger
backend:
serviceName: goldpinger
servicePort: 80
Hey @infinitydon thanks for raising the issue.
I haven't tested it with the nginx ingress, but we should definitely make it work.
I'm not sure why the base url would be needed ? Shouldn't nginx rewrite the paths in a way, that they hit goldpinger
the same way they would if you just curled $IP/raw
etc ?
Could you paste here a curl of the ingress from the outside with a -v
flag, so that we can see what the Location
header resolves to ? That would help. Thanks !
Hi @seeker89
First of all my ingress URL looks like this: https://ingress.domain/goldpinger/
When I click on metrics for example, the URL it is referencing becomes this:
https://ingress.domain/metrics
The URL should be like this: https://ingress.domain/goldpinger/metrics . When I query this directly with curl I get a successful response. The problem is when I access this via a browser.
I suggested a baseURL as this is how most of the projects that needs to be exposed via an ingress are built (e.g. prometheus, grafana, they all are have a parameter to set the baseURL or something like that).
An excerpt from the prometheus doc:
**
--web.external-url=<URL>
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.
`**
Oh, gotcha, so it's just the links that are broken.
We could add the base url, but then we would have to template the static page.
Alternatively, we could probably just change the links in index.html
to something like <li><a href="metrics" >Metrics</a></li>
, to use the same folder, not the root of the current page.
Would you like to give that a try @infinitydon ?
Nice!..
I have edited the index.html as you suggested and created a new image and it works now..
Thanks.. Issue can be closed...