Ingress-nginx主机在服务器段中重定向不起作用
我正在进入入口中的通配符子域,需要重定向任何包含www的子域的请求到nonwww ie: www.randomsubdomain.domain.com
randomsubdomain.domain.com
由于这个原因,我尝试将服务器片段添加到Ingress中,但没有效果,但我已经测试过测试我的正则表达,这符合我的问题,但我的入口似乎被忽略了:
nginx.ingress.kubernetes.io/server-snippet: |
if ($host ~* "^(www\.)([0-9a-z]+\.domain\.com)$") {
return 301 https://$2$request_uri;
}
I'm using wildcard subdomain in the ingress and need to redirect any request that contains subdomain with www to non-www i.e.:www.randomsubdomain.domain.com
to randomsubdomain.domain.com
For this reason I tried to add server snippet to the ingress but it has no effect at all, I have tested my regular expression and it fits my problem but seem to be ignored by my ingress:
nginx.ingress.kubernetes.io/server-snippet: |
if ($host ~* "^(www\.)([0-9a-z]+\.domain\.com)quot;) {
return 301 https://$2$request_uri;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您只需要添加:
To achieve that you just need to add: