3

It is on an amazon server so I checked the following post: Changing Apache document root on AWS EC2 does not work and How to edit httpd.conf file in AMAZON EC2 or in general: How do I change the root directory of an apache server? Well the information provided did help me so far. The only file I could find in the etc/apache2 folder is the following: enter image description here

Edit: The content of the config file is: "Alias /javascript /usr/share/javascript/

Options FollowSymLinks MultiViews "

I asked two month ago on his site: http://www.louisaslett.com/RStudio_AMI/, but didnt get an answer.

My question: How can i change the document root on an RStudio AMI server, so that I can change the directory of the rstudio login page away from the root directory to - say - domain.com/login and have a landing page + other folders on the root (domain.com).

Thank you for your help!

Edit: After the answer from Frédéric Henri and edit:

Here is the content of my rstudio.conf file.

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;
}

Assuming i have the index.html file in the directory /home/idx/index.html, how would i change the file then. The following didnt work for me:

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

Or:

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

and where would i configure to redirect my rstudio login to. Thank you!

Community
  • 1
  • 1
Tonio Liebrand
  • 15,033
  • 3
  • 27
  • 48

1 Answers1

2

You are right and looking at the right place if you were using apache2/httpd web server; but in the case of the RStudio AMI it uses nginx web server so all configuration are stored in /etc/nginx

You can review Configure nginx with multiple locations with different root folders on subdomain to see how you can work with the conf file

In your current configuration, it is defined mainly 3 locations:

  • http://<web_server_ip>/

The conf file used for this case is /etc/nginx/RStudioAMI/rstudio.conf It processes all request and forward to http://localhost:8787 where rstudio is running.

  • http://<web_server_ip>/julia

The conf file used for this case is /etc/nginx/RStudioAMI/julia.conf It processes all request and forward to http://localhost:8000 where julia is running.

  • http://<web_server_ip>/shiny

The conf file used for this case is /etc/nginx/RStudioAMI/shiny.conf It processes all request and forward to http://localhost:3838 where shiny is running.

For example you could have the main location (which is simply / pointing to a specific folder) and changed the rstudio.conf to handle http://<web_server_ip>/rstudio

EDIT

where would i configure to redirect my rstudio login to

If you want the rstudio login page to be accessible from http://<server>/rtudio (for example) you would need to change in the `/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;
}

If you want to point the main http://<server>/index.html pointing to /home/idx/index.html you need to change in /etc/nginx/sites-enabled/RStudioAMI.conf and have a main location defined pointing to your root element

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;
}

Note: Anytime you make a change to a nginx conf file, you need to restart nginx. with: /etc/init.d/nginx restart.

Tonio Liebrand
  • 15,033
  • 3
  • 27
  • 48
Frederic Henri
  • 45,144
  • 6
  • 98
  • 119
  • Hi, thank you so much for your answer, it is already of great help, but i couldnt finish it yet. Could you take another look? – Tonio Liebrand Apr 15 '17 at 09:29
  • Sry, it takes me a while. I try to figure out as much as I can on my own. The solution above didnt work for me yet, but i found another article which was published a few days ago: https://www.r-bloggers.com/shiny-server-series-part-2-running-shiny-on-multiple-ports/, which also points in that direction. – Tonio Liebrand Apr 18 '17 at 07:28
  • would it be possible for you to take another look? – Tonio Liebrand Apr 24 '17 at 13:37