0
votes

How can I redirect a page from an IP address to domain name my.page.com? Everything works when I open the page via my.page.com. When I open via the IP address I get "incorrect certificate "CN = Kubernetes Ingress Controller Fake Certificate O = Acme Co".

I want only to redirect people from an IP address to a domain.

`apiVersion: extensions/v1beta1 kind: Ingress metadata: name: web-ingress annotations: kubernetes.io/ingress.allow-http: "false" nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" spec: tls:

  • hosts:
    • my.page.com secretName: tls-secret rules:
  • host: my.page.com http: paths:
    • path: /api backend: serviceName: api servicePort: 8090
    • path: / backend: serviceName: app servicePort: 8080`

I installed Ingress from here.

2
Stack Overflow is a site for programming and development questions. You should probably use another site on the Stack Exchange network for this question. Also see What topics can I ask about here in the Help Center. - jww
There is a piece of documentation with examples on topic. Will try checking if you can achive IP rewrite - Nick

2 Answers

0
votes

Create a deployment that gives a 404 or nginx 404.html page which do redirect to the main domain.

Then In Ingress deployment pass that service as the default service --default-backend-service=<namespace>/<service>

Which mean, when none of the rules match with the ingress file, then the default service will take that request.

In your case, the IP address would be showing an nginx page that 'page not found', if the default service was not set.

Read here: Default backend

0
votes

There is good documentation with examples on topic.

Generally there are two ways to proceed:

  • modifying the Nginx configuration and adding rewrite rules there. For that, you need to pass new parts of the configuration through the snippets.

  • use an ingress controller like Træfik. Træfik allows you to match specific patter in URL and rewrite it on the fly.