在 RStudio_AMI 上更改文档根目录
Change document root on RStudio_AMI
它在亚马逊服务器上,所以我检查了以下 post:
Changing Apache document root on AWS EC2 does not work
和
或者一般来说: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 登录页面的目录从根目录更改为 - 比如说 - 域。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 登录重定向到
如果您希望可以从 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 conf 文件进行更改,都需要重新启动 nginx。
有:/etc/init.d/nginx restart
.
它在亚马逊服务器上,所以我检查了以下 post:
Changing Apache document root on AWS EC2 does not work
和
或者一般来说: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 登录页面的目录从根目录更改为 - 比如说 - 域。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 登录重定向到
如果您希望可以从 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 conf 文件进行更改,都需要重新启动 nginx。
有:/etc/init.d/nginx restart
.