Configuring RStudio Server service for nginx-ingress in GKE

你离开我真会死。 提交于 2019-12-24 16:26:12

问题


I've a Kubernetes cluster on GKE that has a nginx ingress controller sitting on top to mapping the RStudio Server endpoint under /rstudio/. This works quite well.

Unfortunately, one of my deployments (RStudio Server) doensn't work properly because it uses client-side redirects during the login/logout which end ups in 404 error when trying to access /auth-login (it should be /rstudio/auth-login)

In the past, when using a non-containerized install of RStudio Server, I used to sit an Apache reverse proxy on front to handle url rewrites.

From the official RStudio Server Pro guide i see that adding this location section to nginx.conf should solve the problem.

location /rstudio/ {
  rewrite ^/rstudio/(.*)$ /$1 break;
  proxy_pass http://localhost:8787;
  proxy_redirect http://localhost:8787/ $scheme://$host/rstudio/;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_read_timeout 20d;
}

Can I use annotation on ingress controller to obtain the same results?


回答1:


Although this doesn't end up with the same nginx.conf content, it seems to work. But i don't know if it could cause some side-effects (tested with one pod only atm).

Maybe others would help commenting the answer about...

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rstudio-ingress-nginx
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/add-base-url: "true"
    nginx.ingress.kubernetes.io/proxy-redirect-from: "$scheme://$host/"
    nginx.ingress.kubernetes.io/proxy-redirect-to: "$scheme://$host/rstudio/"
    nginx.ingress.kubernetes.io/proxy-read-timeout: 20d
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/session-cookie-name: "route"
    nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
spec:
  rules:
  - http:
      paths:
      - path: /rstudio/
        backend:
          serviceName: rstudio
          servicePort: 8787


来源:https://stackoverflow.com/questions/52303064/configuring-rstudio-server-service-for-nginx-ingress-in-gke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!