-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Nginx Ingress Controller - the /foo redirection is not working ? #860
Comments
@theobolo can you post a gist with the log of the pod? |
@aledbf There it is : https://gist.github.com/theobolo/48724a1ebeef6296d7bfcc2b4feb9844 It's just the log of one Pod of the DaemonSet where we see the request to /apimobile returns 404 Btw i added the |
@theobolo please execute |
@aledbf Added to the Gist : nginx.conf |
@theobolo please check with the latest version |
@aledbf I checked out the last version but i face the same problem, I tried with many differents frontends but my /foo or /bar redirections always return a 404 error :/ Tried with Jenkins, my API, Dashboard ... In the Nginx Conf i can see the Location rule /apimobile and /jenkins for exemple but it's not working :/ Théo |
@theobolo can you post the new nginx.conf? |
Yep i updated the Nginx.conf on the Gist. There is Jenkins on azureapi.coursierprive.com and on azureapi.coursierprive.com/jenkins but not working on /jenkins. |
oh ! thx i give you my feedback in few minutes ! |
So i tried your image but even if the Location / is putted after the /jenkins in the nginx.conf it's not working :/ I talked with a folk and he thinks that's maybe a problem about the URL asked by Nginx to the Jenkins pod. Maybe the Nginx controller is asking jenkins on http://default-jenkins-80/jenkins ? or somehting similar ? |
Found something about that : http://serverfault.com/questions/444532/reverse-proxy-remove-subdirectory Maybe is only missing a / at the proxy-pass line in the nginx.conf :
|
good point,
same here. When is requires the final slash or not? This is one of the missing things in Ingress. If you have an application (not prepackaged app) you can handle this internally (the redirect) as a workaround. Any idea or feedback is welcomed. |
Thanks for all that stuff, i looked all the issues and for the moment it's a very active problem ;) I think that i'll use the application way as Grafana and the ROOT_URL variable in the YML. I think that the best way is to implement something with Ingress as the Redirect and Rewrite stuff without soliciting the backend app. But the cloud providers apparently are not allowing that :/ Thank you very much for your help Manuel, Cheers, |
@aledbf I was having the same problem with subroutes. I just tried deploying a pod with nginx-ingress-controller:0.7 and it's working now. |
Hey @aledbf it's working well ! I can reach the jenkins Dashboard with the subdirectory /jenkins without changing anything on the controller so it's a good good point ! BTW jenkins is looking for example for some static ressources, even if the path is /jenkins i touch the dahsboard, but the ressources are broken (Css, JS) because it tries to look at /static and not /jenkins/static. I think that not a problem about the rewrite stuff it's a global problem about the Nginx that not able to rewrite all the paths and just making a symbolic link from /jenkins to / : with the real path=/ If i want to touch jenkins at /jenkins without breaking all the dashboard, i still need to modify the ROOT_URL in the Jenkins controller or in my apps to tell to the CSS that the path as changed to /jenkins. So it's very affective for an API or a compute service that not need any attached ressources like a web page. Tell me if i'm wrong and if i missed something about the concept, i'm really thankful about your update ;) |
@theobolo I had the same issue with static assets on jenkins you described but I was able to fix this issue. Are you using the official docker jenkins image? For the official jenkins image you can set the environment variable with
kind: List
apiVersion: v1
items:
- kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: jenkins-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: jenkins
version: 1.651.2-alpine
spec:
containers:
- name: jenkins
image: jenkins:1.651.2-alpine
ports:
- containerPort: 8080
env:
- name: JENKINS_OPTS
value: "--prefix=/jenkins"
- kind: Service
apiVersion: v1
metadata:
name: jenkins
labels:
app: jenkins
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: jenkins
- kind: Ingress
apiVersion: extensions/v1beta1
metadata:
# annotations:
# ingress.kubernetes.io/rewrite-target: / (suggested by @aledbf but it's not necessary if using JENKINS_OPTS above)
name: jenkins-ingress
labels:
app: jenkins
spec:
backend:
rules:
http:
paths:
- path: /jenkins
backend:
serviceName: jenkins
servicePort: 80 |
@fabiormoura Thanks for that but i'm already aware of that possibility i called that the ROOT_URL variable in my previous posts witch is the --prefix that we are using for jenkins there. But by the way that was functional before the rewrite merging, just wondering if the rewrite function could handle that kind of stuff (static ressource rewrite too) without touching or modifying my own apps to add a prefix env variable in the YML or not ;) But thanks for the solution anyway :) |
@theobolo there's an additional annotation Just as an example in your |
thanks @fabiormoura for the example |
@aledbf thanks for that other annotation it's helpfull in my case :D |
@theobolo @fabiormoura suggest contributing to the docs/examples section if you have time, we can always use more good examples |
@theobolo: did you get any luck with running Grafana under ingress controller? i am having trouble with '/grafana' path, 404 error at login page. |
@eghobo I must say that i'm not using Nginx/Ingress controller anymore since the Azure cloud provider implementation gives me PublicIP adresses for eachs applications. Did you change into the Grafana controller the RootPath of the grafana webserver to point to /grafana ? |
@theobolo I figure it out (trailing slash was the issue), see examples below (in case if you are interested) apiVersion: v1
kind: ReplicationController
metadata:
name: grafana-v1
labels:
app: grafana
version: v1
spec:
replicas: 1
selector:
app: grafana
version: v1
template:
metadata:
labels:
app: grafana
version: v1
spec:
containers:
- name: grafana
image: grafana/grafana:3.1.1
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
memory: 100Mi
env:
- name: "GF_SERVER_ROOT_URL"
value: "http://example.com/grafana/"
ports:
- containerPort: 3000
name: ui
protocol: TCP apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: grafana-ingress-v1
annotations:
ingress.kubernetes.io/rewrite-target: /
spec:
tls:
- hosts:
- example.com
secretName: nginx-ingress-tls
rules:
- host: example.com
http:
paths:
- path: /grafana/
backend:
serviceName: grafana
servicePort: 3000 |
@eghobo Thanks for sharing ! Well done |
thanks @eghobo. My working setup (should others find it useful) is this:
Thank you very much for this example, really helpful |
Question: why is the trailing slash needed (/grafana/ vs /grafana)? |
NEED help!!! I'am facing the same problem.
In path /v1 it returned 404 404 Not Foundnginx/1.15.3 ` nginx.conf from the nginx-controller
` |
Hi guys,
I work with the Ingress / Nginx Ingress Controller, but i can't get the /foo redirection working.
I deployed on a Kubernetes cluster a daemonset of Nginx ingress controller, default backend is the http-default-backend example.
This is my ingress object :
My second rule is working but not the first one, if i try to reach my api on : azure.coursierprive.com/apimobile
I face the : backend - 404
I tried with Jenkins portal instead of my API but i face the same problem.
The text was updated successfully, but these errors were encountered: