1

I have application which is running perfectly in docker containers and I am working on migration to Openshift but I am having problems with ingress in Openshift.

Services:

  1. auth (keycloak) reachable on www.website.com/auth -> keycloak UI
  2. Product page reachable on www.website.com/ -> static website UI
  3. Backend reachable on www.website.com/api -> backend API UI

4. Frontend reachable on www.website.com/app -> this should redirect to www.website.com/auth/realm...

Everything is working except the point 4. (redirecting to www.website.com/auth/realm...). When I run www.website.com/app I get 404 Error - Not found (no redirection occures). The setup in docker is working fine with nginx config below. Only in Openshift with current ingress config I get the 404 Error.

Here is my nginx config which is working for docker setup:

proxy_http_version 1.1;
proxy_redirect off;
proxy_pass_request_headers on;
proxy_set_header Host $host;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;

location / {
  set $upstream_host 127.0.0.1;
  set $upstream_port 27002;
  proxy_pass http://$upstream_host:$upstream_port$request_uri;
}

location /auth {
  set $upstream_host 127.0.0.1;
  set $upstream_port 27005;
  proxy_pass https://$upstream_host:$upstream_port$request_uri;
}

location = /app {
  return 302 /app/;
}

location ~ ^(/app)(/.*)$ {
  set $upstream_host 127.0.0.1;
  set $upstream_port 27004;
  proxy_pass http://$upstream_host:$upstream_port$2$is_args$args;
  proxy_set_header X-Forwarded-Prefix $1;
}

Here is my ingress configuration:

    kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
  name: example
  namespace: xzy
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: website.com
      http:
        paths:
          - path: /app
            pathType: ImplementationSpecific
            backend:
              serviceName: service-frontend
              servicePort: 27004
          - path: /api
            pathType: ImplementationSpecific
            backend:
              serviceName: service-backend
              servicePort: 27003
          - path: /
            pathType: ImplementationSpecific
            backend:
              serviceName: service-productpage
              servicePort: 27002
          - path: /auth
            pathType: ImplementationSpecific
            backend:
              serviceName: service-auth
              servicePort: 27001
status:
  loadBalancer: {}
Palino1611
  • 39
  • 2
  • Make sure your `/app` is actually _serving_ the `/app` path. It doesn't get stripped when passing it to the backend...I've been bitten by this in the past. – Will Gordon Jan 06 '21 at 03:41
  • yes it is...when i do curl I get an answer....i just need to redirect the app path to a different one – Palino1611 Jan 14 '21 at 17:10

0 Answers0