Shiny Apps show “Index of …” on CentOS 6.5 VMware virtual machine Shiny server

601 views
Skip to first unread message

Earl Glynn

unread,
Sep 30, 2014, 5:02:53 PM9/30/14
to shiny-...@googlegroups.com
I studied several related posts about this problem, but can't seem to find the trick that works.
 
Are there any words of wisdom from someone successful getting a Shiny server to work on a CentOS box?
After reboot, I login as shiny user …

-          OS Version

[141 shiny localhost 2014-09-30 10:22:43 /home/shiny]

cat /etc/redhat-release

CentOS release 6.5 (Final)

 

- Version of Shiny Server

[142 shiny localhost 2014-09-30 10:23:00 /home/shiny]

shiny-server --version

Shiny Server v1.2.2.366

Node.js v0.10.21

 

-          Shiny apps work locally in R

All shiny apps (shown in directory tree below) work fine when run from the command line with runApp(), e.g.,

[144 shiny localhost 2014-09-30 10:24:40 /home/shiny]

cd /srv/shiny-server/01_hello

 

[145 shiny localhost 2014-09-30 10:24:54 /srv/shiny-server/01_hello]

R

 

R version 3.1.1 (2014-07-10) -- "Sock it to Me"

Copyright (C) 2014 The R Foundation for Statistical Computing

Platform: x86_64-redhat-linux-gnu (64-bit)

 

. . .

 

> library(shiny)

> runApp()

 

Listening on http://127.0.0.1:7271

"Hello Shiny!" app showing "Histogram of x" works fine.
 

- Apache server works fine

Firefox browser shows:

-          "Apache 2 Test Page" at http://localhost

-          "Welcome to Shiny Server" at http://localhost/shiny/

- Modifications to /etc/httpd/conf/http.conf

[148 shiny localhost 2014-09-30 10:28:52 /home/shiny]

tail -12 /etc/httpd/conf/httpd.conf

#<VirtualHost *:80>   

#    ProxyPass / http://localhost:3838/

#    ProxyPassReverse / http://localhost:3838/

#    #ProxyPreservation On

 

    Alias /shiny /srv/shiny-server

    <Directory /srv/shiny-server>

        Options Indexes FollowSymLinks Includes ExecCGI

        Order allow,deny

        Allow from all

    </Directory>

#</VirtualHost>

 

The "VirtualHost" didn't seem to work above, but the Alias did.

 

- Copy of /etc/shiny-server/shiny-server.conf file

[149 shiny localhost 2014-09-30 10:29:04 /home/shiny]

cat /etc/shiny-server/shiny-server.conf

# Instruct Shiny Server to run applications as the user "shiny"

run_as shiny;

 

# Define a server that listens on port 3838

server {

  listen 3838;

 

  # Define a location at the base URL

  location / {

 

    # Host the directory of Shiny Apps stored in this directory

    site_dir /srv/shiny-server;

 

    # Log all Shiny output to files in this directory

    log_dir /var/log/shiny-server;

 

    # When a user visits the base URL rather than a particular application,

    # an index of the applications available in this directory will be shown.

    directory_index on;

  }

}

 

- Copy of /etc/init/shiny-server.conf

[211 shiny localhost 2014-09-30 15:39:06 /home/shiny]

cat /etc/init/shiny-server.conf

# shiny-server.conf

description "Shiny application server"

export R=/usr/bin/R

start on runlevel [2345]

stop on runlevel [016]

limit nofile 1000000 1000000

post-stop exec sleep 5

exec shiny-server --pidfile=/var/run/shiny-server.pid >> /var/log/shiny-server.log 2>&1

# This does not work to set shiny user at startup:

#https://groups.google.com/forum/#!searchin/shiny-discuss/shiny$20user$20exec$20exec/shiny-discuss/_PYf1iB7DUc/VvYO4cgzP-kJ

#exec su -s /bin/sh -c 'exec "$0" "$@"' shiny -- shiny-server --pidfile=/var/run/shiny-server.pid >> /var/log/shiny-server.log 2>&1

respawn limit 3 25

respawn

 

- The directory structure of where you have your applications

[150 shiny localhost 2014-09-30 10:30:01 /home/shiny]

tree /srv/shiny-server

/srv/shiny-server

├── 01_hello

│   ├── DESCRIPTION

│   ├── Readme.md

│   ├── server.R

│   └── ui.R

. . .

├── 11_timer

│   ├── DESCRIPTION

│   ├── Readme.md

│   ├── server.R

│   └── ui.R

├── index.html -> /opt/shiny-server/samples/welcome.html

└── sample-apps -> /opt/shiny-server/samples/sample-apps

13 directories, 45 files

- The URL you are using to access your application(s)

http://localhost/shiny/ [shows "Welcome to Shiny Server" page but only shows Index of /shiny/sample-apps/hello and Index of /shiny/sample-apps/rmd instead of apps.  Both apps should appear since rmarkdown is installed.]

http://localhost/shiny/index.html [same as above]

http://localhost/shiny/02_text/  [shows Index of /shiny/02_text]

If httpd service is stopped, Firefox shows the message "Unable to connect".  After httpd is started, the display changes to "index of …"

- Also, if you see any errors in the /var/log/shiny-server.log file

After reboot

[211 shiny localhost 2014-09-30 15:30:19 /home/shiny]

cat /var/log/shiny-server.log

[2014-09-30 15:28:16.619] [INFO] shiny-server - Shiny Server v1.2.2.366 (Node.js v0.10.21)

[2014-09-30 15:28:16.621] [INFO] shiny-server - Using pidfile /var/run/shiny-server.pid

[2014-09-30 15:28:16.622] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"

[2014-09-30 15:28:16.737] [WARN] shiny-server - Running as root unnecessarily is a security risk! You could be running more securely as non-root.

[2014-09-30 15:28:16.746] [INFO] shiny-server - Starting listener on 0.0.0.0:3838

 

[211 shiny localhost 2014-09-30 15:32:58 /home/shiny]

su root

Password:

[root@localhost shiny]# stop shiny-server

shiny-server stop/waiting

[root@localhost shiny]# exit

exit

 

[211 shiny localhost 2014-09-30 15:33:55 /home/shiny]

/opt/shiny-server/bin/shiny-server

[2014-09-30 15:34:24.350] [INFO] shiny-server - Shiny Server v1.2.2.366 (Node.js v0.10.21)

[2014-09-30 15:34:24.353] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"

[2014-09-30 15:34:24.415] [INFO] shiny-server - Starting listener on 0.0.0.0:3838

 

[2014-09-30 15:33:09.620] [INFO] shiny-server - Stopping listener on 0.0.0.0:3838

[2014-09-30 15:33:09.622] [INFO] shiny-server - Shutting down worker processes (with notification)

 

 

No change in output

http://localhost/shiny/ [shows "Welcome to Shiny Server" page but only shows Index of /shiny/sample-apps/hello and Index of /shiny/sample-apps/rmd instead of apps.  Both apps should appear since rmarkdown is installed.]

http://localhost/shiny/02_text/  [shows Index of /shiny/02_text]

 

What else should I check to figure out why I only see "Index of" for shiny apps?

Thanks for any help.

Fereshteh Karimeddini

unread,
Sep 30, 2014, 5:41:29 PM9/30/14
to shiny-...@googlegroups.com
Earl,

I could be missing something in your posting, but it seems like your Apache server is not correctly proxying to port 3838, where Shiny Server is running on. To start with simple solutions, can you try accessing your applications via direct port access:


What were you seeing when you had this section in your Apache config file:

#<VirtualHost *:80>   

#    ProxyPass / http://localhost:3838/

#    ProxyPassReverse / http://localhost:3838/

#    #ProxyPreservation On



Fereshteh

Fereshteh Karimeddini

unread,
Sep 30, 2014, 5:50:42 PM9/30/14
to shiny-...@googlegroups.com
I should have mentioned, there is a known issue with proxy setup.
Try uncommenting this section of your Apache config file:

#<VirtualHost *:80>   

#    ProxyPass / http://localhost:3838/

#    ProxyPassReverse / http://localhost:3838/

#    #ProxyPreservation On


Then access your application directly:


This should work. The known issue that http://localhost/shiny takes to Welcome page, but does not load the applications. Workaround is to access the application as the above url.

Let us know if you are seeing something different.


Fereshteh


<p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line
...

Earl Glynn

unread,
Sep 30, 2014, 6:32:56 PM9/30/14
to shiny-...@googlegroups.com

I uncommented the lines in the Apache file (/etc/httpd/conf/httpd.conf) except for the “ProxyPreservation On” line, restarted Apache, and tried viewing http://localhost in Firefox.  I saw the message “Service Temporarily Unavailable”, which I also saw yesterday when I first tried this.

I tried http://localhost:3838 and the index.html, which is linked to the welcome.html,  does display, along with the two working shiny apps on that page!!  http://localhost:3838/index.html also works.  So that is very good progress.

Finally, I tried a variation of your suggestion and it works to show the 2nd app:  http://localhost:3838/02_text.  I’ll try some of the other apps tomorrow.

I don’t remember where I got the line “ProxyPreservation On”.  Should that be “ProxyPreserveHost On”? That doesn’t give an error, but I still need to enter all the 3838 port numbers.  Am I missing something that would eliminate the need for all the port numbers?

Thanks much.

Fereshteh Karimeddini

unread,
Oct 1, 2014, 11:54:21 AM10/1/14
to shiny-...@googlegroups.com
I have the following in my /etc/apache2/sites-available/default configuration file to direct Shiny Server traffic to port 80:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        ProxyPass /shiny/ http://localhost:3838/
        ProxyPassReverse /shiny/ http://localhost:3838/shiny http://localhost:3838/
        ProxyPreserveHost On
        RedirectMatch permanent ^/shiny$ /shiny/

Your setup could be different and require changes to this to make it work.


Fereshteh

Earl Glynn

unread,
Oct 1, 2014, 5:59:08 PM10/1/14
to shiny-...@googlegroups.com
With or without the VirturalHost section in /etc/httpd/conf/httpd.conf I get the same thing:
 
http://localhost/   serves what's at /var/www/html/index.html

http://localhost:3838   serves what's at /srv/shiny-server/index.html  (a link to /opt/shiny-server/samples/welcome.html); both shiny apps appear correctly on that HTML page.

Shiny app examples in directories at /srv/shiny-server all work fine:
http://localhost:3838/02_text/
http://localhost:3838/07_widgets/
http://localhost:3838/08_html/
 
But how to get rid of the 3838 port number?
 
I've spent more time than I should on httpd.conf experiments, but nothing is working.  Any suggestions on why the httpd.conf seems to be ignored?  I've even misspelled some of the words in the file so that when I restart the httpd server I can see some errors to make sure the file is being read.
 
Has anyone started with the ISO file for CentOS 6.5 (e.g., from http://mirror.anl.gov/), built a CentOS 6.5 (or other distribution/version) virtual machine using VMware, and then built a ShinyServer on top of that documenting ALL steps along the way?  I'm trying to do that now, but I can't get the ShinyServer configured.    There are so many assumptions, software dependencies, environment variables, permissions, SELinux stuff, ... to get exactly right.

Fereshteh Karimeddini

unread,
Oct 6, 2014, 12:41:02 PM10/6/14
to shiny-...@googlegroups.com
Earl,

Shiny Server by itself seems to be working fine for you at this point. What remains for you is to setup your web server correctly so you can access your applications on port 80. The configuration I posted earlier works fine on my Apache server on Ubuntu. I suggest you consult Apache documentation for more details on how to setup and configure on CentOS:


Best,
Fereshteh
Reply all
Reply to author
Forward
0 new messages