• Welcome to LiuJason's Blog!

Rstudio Server使用Nginx反向代理二级目录 隐藏端口及路径

Linux笔记 Jason 4 years ago (2020-09-24) 540 Views 0 Comments
文章目录[隐藏]

前言

Rstudio的登录页我们一直想要做在同一个域名下,但是每次设置二级目录反代都会失败,例如:
我们设置http://www.a.com/rstudio/反代http://1.1.1.1:8787,那么登录页面访问是正常的,但是登录后rstudio会自动跳转到http://www.a.com:8787/
于是发现除了反代外,还需要写一个rewrite规则。

反代规则案例

#PROXY-START/stu-basic-2/

location /rstudio/
{
    rewrite ^/rstudio/(.*)$ /$1 break;
    proxy_pass http://1.1.1.1:8787/;
	proxy_redirect http://1.1.1.1:8787/ $scheme://$http_host/rstudio/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection upgrade;
    proxy_read_timeout 20d;
    
    #Set Nginx Cache  
    	add_header Cache-Control no-cache;
    expires 12h;
}

#PROXY-END/rstudio/

This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/1023.html
Like (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址