【问题标题】:Change document root on RStudio_AMI更改 RStudio_AMI 上的文档根目录
【发布时间】:2017-08-31 17:18:44
【问题描述】:

它在亚马逊服务器上,所以我查看了以下帖子: Changing Apache document root on AWS EC2 does not workHow to edit httpd.conf file in AMAZON EC2 或者一般来说:How do I change the root directory of an apache server? 到目前为止,所提供的信息确实对我有所帮助。 我可以在 etc/apache2 文件夹中找到的唯一文件如下:

编辑:配置文件的内容是: "别名 /javascript /usr/share/javascript/

选项 FollowSymLinks 多视图 "

两个月前我在他的网站上问过:http://www.louisaslett.com/RStudio_AMI/,但没有得到答案。

我的问题:如何更改 RStudio AMI 服务器上的文档根目录,以便我可以将 rstudio 登录页面的目录从根目录更改为 - 比如说 - domain.com/login 并拥有一个登录页面+ 根目录 (domain.com) 上的其他文件夹。

感谢您的帮助!

编辑: 在 Frédéric Henri 的回答和编辑之后:

这是我的 rstudio.conf 文件的内容。

location / {
  proxy_pass http://localhost:8787;
  proxy_redirect http://localhost:8787/ $scheme://$host/;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_read_timeout 20d;
  access_log /var/log/nginx/rstudio-access.log;
  error_log  /var/log/nginx/rstudio-error.log;
}

假设我在目录 /home/idx/index.html 中有 index.html 文件,那么我将如何更改该文件。 以下对我不起作用:

  proxy_pass http://localhost/home/idx;
  proxy_redirect http://localhost/home/idx/ $scheme://$host/;

或者:

  proxy_pass /home/idx;
  proxy_redirect /home/idx/ $scheme://$host/;

以及我将在哪里配置以将我的 rstudio 登录重定向到。 谢谢!

【问题讨论】:

  • 你能把列出的conf文件的内容贴出来吗?
  • 感谢您的评论。我在帖子中进行了编辑。

标签: r ubuntu amazon-ec2 rstudio amazon-ami


【解决方案1】:

如果您使用的是 apache2/httpd 网络服务器,那么您是对的,并且正在寻找正确的位置;但对于 RStudio AMI,它使用 nginx web server,因此所有配置都存储在 /etc/nginx

您可以查看 Configure nginx with multiple locations with different root folders on subdomain 以了解如何使用 conf 文件

在你当前的配置中,主要定义了3个位置:

  • http://<web_server_ip>/

本案例使用的conf文件是/etc/nginx/RStudioAMI/rstudio.conf,它处理所有请求并转发到运行rstudio的http://localhost:8787

  • http://<web_server_ip>/julia

本案例使用的 conf 文件是 /etc/nginx/RStudioAMI/julia.conf 它处理所有请求并转发到运行 julia 的 http://localhost:8000

  • http://<web_server_ip>/shiny

本案例使用的conf文件是/etc/nginx/RStudioAMI/shiny.conf,它处理所有请求并转发到正在运行shiny的http://localhost:3838

例如,您可以拥有主要位置(只是 / 指向特定文件夹)并更改 rstudio.conf 以处理 http://<web_server_ip>/rstudio

编辑

我将在哪里配置以将我的 rstudio 登录重定向到

如果您希望可以从http://<server>/rtudio 访问 rstudio 登录页面(例如),您需要在 `/etc/nginx/RStudioAMI/rstudio.conf` 中进行更改

location /rstudio/ {
  proxy_pass http://localhost:8787/;
  proxy_redirect http://localhost:8787/ $scheme://$host/;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_read_timeout 20d;
  access_log /var/log/nginx/rstudio-access.log;
  error_log  /var/log/nginx/rstudio-error.log;
}

如果您想将主要的http://<server>/index.html 指向/home/idx/index.html,您需要更改/etc/nginx/sites-enabled/RStudioAMI.conf 并定义一个指向您的根元素的主要位置

map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

server {
  listen 80 default_server;
  index index.html;

  location = / {
      root /var/www/html;
  }

  include /etc/nginx/RStudioAMI/*.conf;
}

注意:任何时候对 nginx 配置文件进行更改,都需要重新启动 nginx。 与:/etc/init.d/nginx restart.

【讨论】:

  • 您好,非常感谢您的回答,已经很有帮助了,但我还没有完成。你能再看看吗?
  • 对不起,这需要我一段时间。我尽量自己想办法。上面的解决方案对我来说还没有用,但是我找到了几天前发表的另一篇文章:r-bloggers.com/…,它也指向了那个方向。
  • 你能再看看吗?
猜你喜欢
  • 1970-01-01
  • 2012-04-26
  • 2016-05-23
  • 2016-06-21
  • 2017-06-25
  • 2019-03-23
  • 2014-02-23
  • 2016-04-17
  • 1970-01-01
相关资源
最近更新 更多