是否可以通过任何方式将主机路径重定向到后端的子路径? subPaths处理卷的方式类似。
入口看起来像这样:
Mutation: {
signUpFirstStep: async ( parent, { number }, { models, secret }) =>
{
nexmo.verify.request({
number: number,
brand: 'Nexmo',
code_length: '4'
}, (err, result) => {
if(result) {
const requestId = result.request_id;
console.log(requestId); // you should console.log or do whatever you are trying to do with the requestId here
}
});
}
}
导航到apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: jupyter-notebook-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: jptrntbk.MYDOMAIN.com
http:
paths:
- path: /
backend:
serviceName: jupyter-notebook-service
servicePort: 8888
subPath: /lab
会在后端重定向到jptrntbk.MYDOMAIN.com
,并且所有其他父路径都不可用。
答案 0 :(得分:1)
创建带有应用程序根注释的Ingress规则:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/app-root: /app1
name: approot
namespace: default
spec:
rules:
- host: approot.bar.com
http:
paths:
- backend:
serviceName: http-svc
servicePort: 80
path: /
检查重写是否正常
$ curl -I -k http://approot.bar.com/
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.11.10
Date: Mon, 13 Mar 2017 14:57:15 GMT
Content-Type: text/html
Content-Length: 162
Location: http://stickyingress.example.com/app1
Connection: keep-alive
还是可以创建带有重写注释的Ingress规则:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: rewrite
namespace: default
spec:
rules:
- host: rewrite.bar.com
http:
paths:
- backend:
serviceName: http-svc
servicePort: 80
path: /something(/|$)(.*)
在此入口定义中,(.*)
捕获的所有字符都将分配给占位符$2
,然后将其用作rewrite-target
批注中的参数。
例如,上面的入口定义将导致以下重写:- rewrite.bar.com/something
重写为rewrite.bar.com/
-rewrite.bar.com/something/
重写为rewrite.bar.com/
-rewrite.bar.com/something/new
重写为rewrite.bar.com/new