patternMinor
Nginx ingress controller redirects the url to /login
Viewed 0 times
ingresstheloginnginxcontrollerredirectsurl
Problem
I am trying to access a url example.com/service/test1 but it redircts me to example.com/login.
Below is my YAMl file:
Below is my YAMl file:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ing
namespace: test
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx-ingress.kubernetes.io/use-regex: true
spec:
rules:
- host: example.com
http:
paths:
- backend:
serviceName: svc-test
servicePort: 8080
path: /service/test
tls:
- secretName: tls-secretSolution
It just works
Your configuration is correct.
Provided
Testing this config via this cool tester shows that location filter works:
For more details, see this explanation of Ingress Path Matching and examples from NGINX Docs:
Check your app
Check your app, maybe it forward non-authorized requests to
You may use
Howto debug
There is an
To enable it, use
See: k8s debug logging:
Using the flag
Your configuration is correct.
Provided
YAML file generates nginx config like this:...
server {
listen 80;
server_name example.com;
...
location ~* "^/service/test" {
root /var/www/example.com/htdocs;
}
}Testing this config via this cool tester shows that location filter works:
http://example.com/service/test1->Location: ^/service/test
http://example.com/service/test->Location: ^/service/test
http://example.com/login->Errors: No locations matched
For more details, see this explanation of Ingress Path Matching and examples from NGINX Docs:
- Examples show how to use advanced NGINX features in Ingress resources with annotations.
- Examples of Custom Resources show how to use VirtualServer and VirtualServerResources for a few use cases.
Check your app
Check your app, maybe it forward non-authorized requests to
/login url.You may use
curl -v or wget, e.g:curl -v -L http://example.com/service/test1 | egrep "^> (Host:|GET)"wget http://example.com/service/test1 2>&1 | grep LocationHowto debug
nginx ingressThere is an
Nginx debug mode for debugging nginx locations and redirects.To enable it, use
--v=5 in kubectl edit deploy.See: k8s debug logging:
Using the flag
--v=XX it is possible to increase the level of logging. This is performed by editing the deployment.$ kubectl get deploy -n
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
default-http-backend 1 1 1 1 35m
nginx-ingress-controller 1 1 1 1 35m
$ kubectl edit deploy -n nginx-ingress-controller
# Add --v=X to "- args", where X is an integer--v=2shows details usingdiffabout the changes in the configuration in nginx
--v=3shows details about the service, Ingress rule, endpoint changes and it dumps the nginx configuration in JSON format
--v=5configures NGINX in debug mode
Code Snippets
...
server {
listen 80;
server_name example.com;
...
location ~* "^/service/test" {
root /var/www/example.com/htdocs;
}
}curl -v -L http://example.com/service/test1 | egrep "^> (Host:|GET)"wget http://example.com/service/test1 2>&1 | grep Location$ kubectl get deploy -n <namespace-of-ingress-controller>
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
default-http-backend 1 1 1 1 35m
nginx-ingress-controller 1 1 1 1 35m
$ kubectl edit deploy -n <namespace-of-ingress-controller> nginx-ingress-controller
# Add --v=X to "- args", where X is an integerContext
StackExchange DevOps Q#11199, answer score: 3
Revisions (0)
No revisions yet.