publish shiny App on my own Linux server with a custom URL

1,711 views
Skip to first unread message

姚文

unread,
Mar 5, 2015, 9:46:30 AM3/5/15
to shiny-...@googlegroups.com
Hi guys,

I want to publish my shiny App on my own Linux server. When use the IP and port 3838 to publish my App (the default configuration of shiny server), everything is okay. However port 3838 is blocked by the firewall of my University, so my App could not be accessed from outside of my University. So I decided to use port 80 and use a custom URL for my App. 

The IP of my server is 211.69.128.148. I created a domain name "ricencode.ncpgr.cn" and bind it to this IP.

Here is the configuration file of shiny server.
cat /etc/shiny-server/shiny-server.conf

run_as shiny
;

server
{
  listen
80;

  server_name ricencode
.ncpgr.cn;
  location
/ {
    site_dir
/srv/shiny-server;
    log_dir
/var/log/shiny-server;
 
}
}


My App is in this directory:
ls /srv/shiny-server/RICENCODE/
data  famInfo
.table  geneInfo.table  geneKeyword.table  google-analytics.js  rapmsu.rda  README.md  reference.table  script  server.R  shinyapps  ui.R  www

However, the URL "http://ricencode.ncpgr.cn/RICENCODE/" is not working.

What should I do to make my shiny App running on my server and accessible from outside of my university?
Should I configure this file "httpd.conf"?

Thanks in advance!


Joe Cheng

unread,
Mar 5, 2015, 10:23:43 AM3/5/15
to 姚文, shiny-...@googlegroups.com
Do you have an index.html file in /srv/shiny-server/, whose contents is "hello world!"?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/d2778463-ed27-42a6-9610-d65c164a5304%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

姚文

unread,
Mar 5, 2015, 8:37:00 PM3/5/15
to shiny-...@googlegroups.com, ywh...@gmail.com
Yes.  I also added the following lines into "/etc/httpd/conf/httpd.conf".

<VirtualHost *:80>
 ServerName 211.69.128.148
 ServerAlias ricencode.ncpgr.cn
 DocumentRoot "/srv/shiny-server"
 
 <Directory "/srv/shiny-server">
   Order Allow,Deny
   Allow from all
 </Directory>
 <Directory "/srv/shiny-server/RICENCODE">
   Order Allow,Deny
   Allow from all
 </Directory>
</VirtualHost>

This is probably not correct. But if I did not modify "httpd.conf" and delete "index.html" from /srv/shiny-server/, the shiny App would not work either.

Thanks!

Joe Cheng

unread,
Mar 6, 2015, 2:59:30 AM3/6/15
to 姚文, shiny-...@googlegroups.com
OK, let's take a step back.

You have both Apache and Shiny Server configured to listen on port 80. That is certainly not going to work. I think the first question is whether you actually need Apache for anything. The simplest would be to shut down Apache (or configure it to stop listening on port 80, and reload) and restart Shiny Server, and I think that should start working.

If you do need to have Apache listening on port 80 (for example if you have other web stuff you are serving using other URL paths on the same host/port) then what you want to do is not serve up a <Directory>, but rather, proxy that traffic through to Shiny Server. To do this, change Shiny Server back to listening on port 3838 and remove the server_name directive, then set ProxyPass and ProxyPassReverse directives in your Apache config. Probably something like this:

ProxyPassReverse / http://127.0.0.1:3838/

If that doesn't work, first try viewing port 3838 from inside the firewall to see if the Shiny Server instance is even working. If that works, then check the Apache logs to see why the proxying is failing.

姚文

unread,
Mar 6, 2015, 4:25:59 AM3/6/15
to shiny-...@googlegroups.com, ywh...@gmail.com
This is the solution! Thanks so much! I got another question about shiny server. I will create a new post for that question.

Ben Porter

unread,
May 2, 2015, 11:40:31 PM5/2/15
to shiny-...@googlegroups.com
Thanks Joe!  Helpful as always.

I also had apache trying to run on port 80 at the same time.  I didn't need it my case, so here is how I disabled it on my Ubuntu 14.04 server.

sudo update-rc.d apache2 disable

Reply all
Reply to author
Forward
0 new messages