gpt4 book ai didi

r - 更改 RStudio_AMI 上的文档根目录

转载 作者:太空宇宙 更新时间:2023-11-03 16:57:00 24 4
gpt4 key购买 nike

它在亚马逊服务器上,所以我检查了以下帖子: 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 文件夹中找到的唯一文件如下: enter image description here

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

选项 FollowSymLinks 多 View "

我两个月前在他的网站上问过: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 登录重定向到。谢谢!

最佳答案

如果您使用的是 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它处理所有请求并转发到 http://localhost:8787 rstudio 运行的地方。

  • http://<web_server_ip>/julia

用于此案例的 conf 文件是 /etc/nginx/RStudioAMI/julia.conf它处理所有请求并转发到 http://localhost:8000 Julia 跑的地方。

  • http://<web_server_ip>/shiny

用于此案例的 conf 文件是 /etc/nginx/RStudioAMI/shiny.conf它处理所有请求并转发到 http://localhost:3838 Shiny 运行的地方。

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

编辑

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

如果您希望 rstudio 登录页面可以从 http://<server>/rtudio 访问(例如)您需要更改`/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 conf 文件进行更改,都需要重新启动 nginx。与:/etc/init.d/nginx restart .

关于r - 更改 RStudio_AMI 上的文档根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43242258/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com