I have an kubernetes ingress(nginx)
My ingress :
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: backend-ingress-nginx
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
set $abcde "ank";
nginx.ingress.kubernetes.io/server-snippet: |
proxy_cache_key "$scheme$request_method$host$http_origin$request_uri";
proxy_cache_valid 200 1h;
proxy_cache_methods GET POST;
proxy_ignore_headers Set-Cookie;
location ~ (facadev2/api/v[0-9]+/info/getCourseDetailPage) {
proxy_cache akamai_sa_acp;
proxy_cache_valid 200 168h;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_pass http://facade-nodeport;
}
spec:
rules:
- host: apis2.test.com
http:
paths:
- path: /facadev2
backend:
serviceName: facade-nodeport
servicePort: 80
Now the issue here is what should I use as proxy_pass in server-snippet. Currently it is giving error as :
[emerg] host not found in upstream "facade-nodeport" in /tmp/nginx-cfg929796726:450
So, to reply exactly your question - yes, you are correct - it should be http://facade-nodeport and you specified it correct. Unfortunately I wasnt able to find right now, but if im not mistake - there was an limitation for regular Nginx ingress that allowed you only 1 rewrite/snippet section. More options were in paid Plus version. I will put this question as community support to easily edit this post in case of new info. Also i'll add justification url once find it. Maybe this is an explanation in your situation.
What I can also propose - you can redo your ingress, put the proxy_pass http://facade-nodeport;
away from snippet and add facadev2/api/v[0-9]+/info/getCourseDetailPage
as a new path that will be mapped with facade-nodeport service.
smth like
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: backend-ingress-nginx
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
set $abcde "ank";
nginx.ingress.kubernetes.io/server-snippet: |
proxy_cache_key "$scheme$request_method$host$http_origin$request_uri";
proxy_cache_valid 200 1h;
proxy_cache_methods GET POST;
proxy_ignore_headers Set-Cookie;
location ~ (facadev2/api/v[0-9]+/info/getCourseDetailPage) {
proxy_cache akamai_sa_acp;
proxy_cache_valid 200 168h;
add_header X-Proxy-Cache $upstream_cache_status;
}
spec:
rules:
- host: apis2.test.com
http:
paths:
- path: /facadev2/api/v[0-9]+/info/getCourseDetailPage
backend:
serviceName: facade-nodeport
servicePort: 80
I havent reproduced this code, so please if you would try it - adapt correct syntax for /facadev2/api/v[0-9]+/info/getCourseDetailPage
and check what you have in the end in nginx.conf
after applying.