问题
I have Sentry running in my cluster and i want to expose it on subpath using nginx ingress but it seems that it only works on root path, i tried several ways but it didn't work. Is there any configuration i can perform in order to make it work on a subpath because i've seen some examples using these two variables in the sentry.conf.py file:
SENTRY_URL_PREFIX = '/sentry'
FORCE_SCRIPT_NAME = '/sentry'
But i don't know if it works
Here is the ingress resource for sentry :
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: "sentry-ingress"
namespace: "tools"
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
labels:
app: sentry-ingress
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: "sentry"
servicePort: 9000
回答1:
Your ingress does not work properly.
In nginx ingress docs you can read:
IMPORTANT NOTES: If the
use-regex
ORrewrite-target
annotation is used on any Ingress for a given host, then the case insensitive regular expression location modifier will be enforced on ALL paths for a given host regardless of what Ingress they are defined on.
Meaning that when you use rewrite-target annotation, path
field value is treated as regexp and not as a prefix. This is why path: /
is matched literally and only with /
.
So if you want to use rewrite-target you should do it as following:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: sentry-ingress
namespace: tools
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$1
labels:
app: sentry-ingress
spec:
rules:
- http:
paths:
- path: /sentry/(.*)
backend:
serviceName: sentry
servicePort: 9000
来源:https://stackoverflow.com/questions/61737995/how-to-expose-sentry-on-subpath-in-nginx-ingress