PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, August 13, 2022

[FIXED] How to service multiple solution webui through one port using k8s ingress service

 August 13, 2022     kubernetes, nginx-ingress     No comments   

Issue

I need to service gitlab, nexus and jupyterhub based on URL using one open port using k8s ingress.

If the path is written as "/" when create ingress, it works normally, but if you write "/nexus" like this, a problem occurs during the redirection process.

Have any of you solved the same problem? Please help.

enter image description here

my ingress.yaml as below

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  creationTimestamp: "2022-04-06T05:56:40Z"
  generation: 7
  name: nexus-ing
  namespace: nexus
  resourceVersion: "119075924"
  selfLink: /apis/extensions/v1beta1/namespaces/nexus/ingresses/nexus-ing
  uid: 4b4f97e4-225e-4faa-aba3-6af73f69c21d
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - backend:
          serviceName: nexus-service
          servicePort: 8081
        path: /nexus(/|$)(.*)
        pathType: ImplementationSpecific
status:
  loadBalancer:
    ingress:
    - ip: 172.30.1.87

Solution

That's a problem with nexus itself. Your ingress works as intended, and you cannot do more from this side.

The problem here is that nexus webpage, i.e. index.html, requests resources in such a way that it's looking at the wrong place. You can see this by opening the network tab and inspecting the request URL of the missing statics.

To see what I mean, let's examine the below HTML image tags.

<img id="1" src="./statics/some-image.svg" alt="some image" />

<img id="2" src="/statics/some-image.svg" alt="some image" />

You can see that the first one, is using relative path, and would work with your configuration since the request URL would be relative to the location in the browser and then the nexus part gets stripped by the ingress controller.

However, the second one is using absolute path, so it will not have the nexus part in the request URL and the ingress controller will not be able to route it to the correct service.

This is a common problem when stripping path prefixes. It only works fully when the application you are serving when stripping a prefix is correctly configured.

In your case this means, checking the documentation of the services, if you have any way to influence this.

It may be more straight forward to route based on hostname instead of path. I.e nexus.myhost.com. For that, you would need a domain and point the corresponding A records to your ingress services IP / use a wildcard record.



Answered By - The Fool
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing