0

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

2 Answers 2

0

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.