Ingress rule for multiple paths not working as expected

2/21/2019

here is the situation: I have 2 deployments running for sonarqube (for different use cases) linked to 2 different services and I am redirecting traffic through Ingress path based routing.

metadata:
  annotations:    
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
  name: sonarqube
  namespace: sonar-namespace
spec:
 rules:
  - host: sonar.example.com
    http:
      paths:
      - backend:
          serviceName: sonar-service-1
          servicePort: 80
        path: /sonarqube/
      - backend: 
          serviceName: sonar-service-2
          servicePort: 80
        path: /sonarqube-two/

I am able to access UI page under /sonarqube and under /sonarqube-two/ as well but whenever I am trying to take any action (say installing new plugins, creating new user etc) it's redirecting me to login page every single time. Could someone please help me this? Let me know if any information is required from my side.

-- AshitAcharya
kubernetes
kubernetes-ingress
nginx-ingress
sonarqube

2 Answers

2/21/2019

You need to tell Sonarqube the path in which it is running, if you're not using the default path /.

You can set that by setting

sonar.web.context=/sonarqube

in $SONARQUBE-HOME/conf/sonar.properties

Taken from the official documentation: https://docs.sonarqube.org/latest/setup/install-server/ (Starting the Web Server)

An alternative approach would be to use subdomains instead of paths to host it (e.g. sonar1.example.com and sonar2.example.com). Then you wouldn't need to modify your configuration.

-- Pampy
Source: StackOverflow

2/21/2019

Never thought that issue would be with cache and cookies! Opened a new browser(firefox) and cleared all the history, cache, and cookies and after that, all started working. Now being able to open and take POST actions on both the URLs. Thanks Harsh and Pampy for taking out time and helping me out.

-- AshitAcharya
Source: StackOverflow