入口NginX主机,其基本域指向默认后端

时间:2019-11-26 21:44:00

标签: kubernetes nginx-ingress

我试图通过指向domain.coom而不是www.domain.com来访问我的网站 使用基本域而不是子域。

每当我使用子域时,它都可以正常工作,但是当我切换到基本域时,它指向默认后端。

具有子域的入口:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: web-ingress
  namespace: th3-website
  labels:
    app: web
    environment: prod
spec:
  rules:
    - host: www.domain.com
      http:
        paths:
          - backend:
              serviceName: web-service
              servicePort: 80

并卷曲:

HTTP/1.1 302 Found
Content-Type: text/html; charset=UTF-8
Date: Tue, 26 Nov 2019 21:34:24 GMT
Location: /talent
Server: openresty/1.15.8.2
Set-Cookie: lang=en; expires=Sun, 23-Jul-9116 21:34:24 GMT; path=/; domain=.domain.com
Set-Cookie: country=my; expires=Sun, 23-Jul-9116 21:34:24 GMT; path=/; domain=.domain.com
X-Powered-By: PHP/7.2.25
Connection: keep-alive

但是当我切换到基本域时

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: web-ingress
  namespace: th3-website
  labels:
    app: web
    environment: prod
spec:
  rules:
    - host: domain.com
      http:
        paths:
          - backend:
              serviceName: web-service
              servicePort: 80

卷曲(curl -I domain.com)的结果:

TTP/1.1 200 OK
accept-ranges: bytes
Content-Length: 338
Content-Type: text/html
Date: Tue, 26 Nov 2019 21:35:46 GMT
etag: "5cc81b56-152"
last-modified: Tue, 30 Apr 2019 09:54:30 GMT
Server: openresty/1.15.8.2
Vary: Accept-Encoding
x-envoy-decorator-operation: maintenance.default.svc.cluster.local:80/*
x-envoy-upstream-service-time: 0
Connection: keep-alive

卷曲(curl -I domain.com/talent)的结果:

HTTP/1.1 404 Not Found
Content-Length: 154
Content-Type: text/html
Date: Tue, 26 Nov 2019 21:36:04 GMT
Server: openresty/1.15.8.2
x-envoy-decorator-operation: maintenance.default.svc.cluster.local:80/*
x-envoy-upstream-service-time: 0
Connection: keep-alive

如何与其他使用子域的服务一起使用基本域而不是子域?

试图找到一种方法但无济于事,我们将不胜感激! 如果可能的话,这是我的入口控制器日志:

I1126 21:40:43.271131       6 controller.go:134] Configuration changes detected, backend reload required.
I1126 21:40:43.458881       6 controller.go:150] Backend successfully reloaded.
xxx.xxx.xxx.xxx - - [26/Nov/2019:21:40:58 +0000] "HEAD /talent HTTP/1.1" 404 0 "-" "curl/7.64.1" 188 0.004 [default-maintenance-80] [] xxx.xxx.xxx:80 0 0.004 404 xxx
xxx.xxx.xxx.xxx - - [26/Nov/2019:21:41:51 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/7.64.1" 182 0.004 [default-maintenance-80] [] xxx.xxx.xxx.xxx:80 0 0.004 200 xxx

0 个答案:

没有答案