入口将域 www 重写为非 www url
ingress rewrite domain www to non-www url
我正在尝试将我的域 'www.test.example.com' 重定向到 test.example.com
在入口中我添加了注释
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($host = 'www.test.wotnot.io' ) {
rewrite ^/(.*)$ https://app.test.wotnot.io/ permanent;
}
它没有按预期工作。
为了测试,我尝试了这个
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($host = 'test.example.com' ) {
rewrite ^/(.*)$ https://google.com/ permanent;
}
工作正常。
我的站点正在处理 test.example.com
和 ssl 证书。
整个入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
certmanager.k8s.io/cluster-issuer: wordpress-staging
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
#nginx.ingress.kubernetes.io/configuration-snippet: |
#if ($host = 'www.test.wotnot.io' ) {
# rewrite ^/(.*)$ https://test.example.io/ permanent;
#}
name: wordpress-staging-ingress
spec:
rules:
- host: test.example.io
http:
paths:
- backend:
serviceName: wordpress-site
servicePort: 80
path: /
tls:
- hosts:
- test.example.io
secretName: wordpress-staging
Ingress 有一个注解 nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
已经处理了这个:
In some scenarios is required to redirect from www.domain.com
to
domain.com
or vice versa. To enable this feature use the annotation
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
Attention: For HTTPS to HTTPS redirects is mandatory the SSL Certificate defined in the Secret, located in the TLS section of Ingress, contains both FQDN in the common name of the certificate.
最好使用它而不是 fighting/tweaking configuration-snippet
注释。
我正在尝试将我的域 'www.test.example.com' 重定向到 test.example.com
在入口中我添加了注释
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($host = 'www.test.wotnot.io' ) {
rewrite ^/(.*)$ https://app.test.wotnot.io/ permanent;
}
它没有按预期工作。
为了测试,我尝试了这个
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($host = 'test.example.com' ) {
rewrite ^/(.*)$ https://google.com/ permanent;
}
工作正常。
我的站点正在处理 test.example.com
和 ssl 证书。
整个入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
certmanager.k8s.io/cluster-issuer: wordpress-staging
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
#nginx.ingress.kubernetes.io/configuration-snippet: |
#if ($host = 'www.test.wotnot.io' ) {
# rewrite ^/(.*)$ https://test.example.io/ permanent;
#}
name: wordpress-staging-ingress
spec:
rules:
- host: test.example.io
http:
paths:
- backend:
serviceName: wordpress-site
servicePort: 80
path: /
tls:
- hosts:
- test.example.io
secretName: wordpress-staging
Ingress 有一个注解 nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
已经处理了这个:
In some scenarios is required to redirect from
www.domain.com
todomain.com
or vice versa. To enable this feature use the annotationnginx.ingress.kubernetes.io/from-to-www-redirect: "true"
Attention: For HTTPS to HTTPS redirects is mandatory the SSL Certificate defined in the Secret, located in the TLS section of Ingress, contains both FQDN in the common name of the certificate.
最好使用它而不是 fighting/tweaking configuration-snippet
注释。