在GKE中为Nginx入口配置RStudio Server服务 [英] Configuring RStudio Server service for nginx-ingress in GKE
问题描述
我在GKE上有一个Kubernetes集群,它的顶部有一个nginx入口控制器,用于映射/rstudio/下的RStudio Server端点.效果很好.
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.
不幸的是,我的一个部署(RStudio Server)无法正常工作,因为它在登录/注销期间使用了客户端重定向,在尝试访问/auth-login时最终会出现404错误(应该是/rstudio /auth-login)
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)
过去,当使用非容器化的RStudio Server安装时,我曾经在前面放置一个Apache反向代理来处理URL重写.
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.
来自官方RStudio Server Pro指南我看到将location
部分添加到nginx.conf
应该可以解决问题.
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?
推荐答案
尽管最终并没有相同的nginx.conf
内容,但它似乎可以正常工作.但是我不知道它是否会引起一些副作用(仅在一个atm机上测试过).
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
这篇关于在GKE中为Nginx入口配置RStudio Server服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!