Proxy Shiny?

1,913 views
Skip to first unread message

Greg Sterijevski

unread,
Jun 22, 2013, 7:38:55 PM6/22/13
to shiny-...@googlegroups.com
Hello All,

First, Shiny is awesome.

Second, I have succeeded in running Shiny through a NGINX proxy. Everything works as long as I do not turn on SSL. Has anyone had any luck in proxying the Shiny App through NGINX with SSL? (Apache would do as well). Looking at the message traffic, it does not seem like the Shiny app is passing an Origin tag in the header. I am not sure that this is even important. The error that occurs is that an exception is throw in shiny.js on the creation of the websocket (line 453).

Thank you,

-Greg  

 

Greg Sterijevski

unread,
Jun 25, 2013, 7:53:24 PM6/25/13
to shiny-...@googlegroups.com
Here is the proxy config which seems to work on http. The Shiny App runs on port 8100 in the local host. I proxy the connection on port 7070.

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       8080;
        server_name  localhost;

        #access_log  logs/host.access.log  main;
        location / {
            root   html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    server {
        listen       7070;
        root         html;
        index        index.html index.htm;
        server_name  linux-ef1t.site;
        location / {
                error_log  logs/proxy_error_http.log  info;
                proxy_pass http://localhost:8100;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }
    }
}

Does anyone see why this would fail if https?

Greg Sterijevski

unread,
Jun 28, 2013, 11:37:42 PM6/28/13
to shiny-...@googlegroups.com

I have also tried to proxy using Stunnel. I get the same issue. The page comes up, the socket throws an exception. The page looks static. Could there be an issue in the Shiny,js code?

Sarven Capadisli

unread,
Jul 1, 2013, 12:30:14 PM7/1/13
to shiny-...@googlegroups.com
On 06/23/2013 01:38 AM, Greg Sterijevski wrote:
> Second, I have succeeded in running Shiny through a NGINX proxy.
> Everything works as long as I do not turn on SSL. Has anyone had any
> luck in proxying the Shiny App through NGINX with SSL? (Apache would do
> as well). Looking at the message traffic, it does not seem like the
> Shiny app is passing an Origin tag in the header. I am not sure that
> this is even important. The error that occurs is that an exception is
> throw in shiny.js on the creation of the websocket (line 453).

Anyone reverse proxying with Apache and trying to get websockets working?

It sounds like we have a similar issue. I'm using Apache and have a
reverse proxy to shiny server like:

RewriteRule ^/(.*) http://localhost:8100/?x=$1 [P]

When I load http://example.org/foo I get the following JavaScript error:

Firefox can't establish a connection to the server at ws://localhost/.
http://localhost/shiny/shiny.js
Line 440

What I understand after some digging around is that, Apache 2.2 (current
stable) doesn't have a module for reverse proxy for websockets. So, I
tried the instructions at:

http://www.amoss.me.uk/2013/06/apache-2-2-websocket-proxying-ubuntu-mod_proxy_wstunnel

I think I was able to enable the module fine, however, I now get this issue:

The requested URL /ws://localhost:8100/ was not found on this server.

Notice the / before ws.

-Sarven

Sarven Capadisli

unread,
Jul 1, 2013, 1:11:33 PM7/1/13
to shiny-...@googlegroups.com
What do you mean by proxying the connection at 7070 when you have shiny
running at 8100? What's the external URL with port in the end?

Would you mind giving a quick how-to for your test above?

Using Apache, my goal (see my earlier reply) is to take a request like
http://example.org/foo/bar and send it to shiny server like
http://localhost:8100/?x=foo&y=bar

-Sarven


Greg Sterijevski

unread,
Jul 1, 2013, 3:01:55 PM7/1/13
to shiny-...@googlegroups.com
Hi Sarven!



What do you mean by proxying the connection at 7070 when you have shiny
running at 8100? What's the external URL with port in the end?


The external url would be http://192.168.0.6:8100 (if a user inside the LAN is using the Shiny App). On the server (192.168.0.6), the WebSocket is listening for activity on the 7070 port. In other words,I issue ::runapp( './', port  = 7070) on the R side. Truthfully, I am not interested in users behind the firewall. I was using the unencrypted proxy for proof of concept. I was not sure that it would be possible to proxy a websocket request. It looks like it is. Ideally, I would like to use the reverse proxy as a way to use Apache or NGINX to do user authentication. I am stuck on making the proxy work with https. The initial request works, the webapp comes up, but it is not interactive. If I have a simple web app consisting of a slider and a data table with one cell and I attempt to display the value of the slide in the cell, the slider and table all get rendered, but moving the slider does nothing (the value does not change in the table). In firefox, the failure is silent. In Opera, the failure is listed as a DOMException. It looks like the fact that the proxy terminates the SSL connection at the NGINX server, but forwards an http:// (ws://) request to the Shiny backend is generating a Cross Domain Exception. I have also tried the same thing with STUNNEL and still have the same issue. 

 
Would you mind giving a quick how-to for your test above?


Sure, where and how would like to me to do so?
 
Using Apache, my goal (see my earlier reply) is to take a request like
http://example.org/foo/bar and send it to shiny server like
http://localhost:8100/?x=foo&y=bar


Shouldn't a rewrite with a reverse proxy work? I will look at your attachment a bit more closely.
 
-Sarven


-Greg


 

Joe Cheng

unread,
Jul 1, 2013, 5:34:26 PM7/1/13
to shiny-...@googlegroups.com
In Chrome's developer tools, what does it say in the Network tab? Is there a request to cdn.sockjs.org being made, and if so, is it succeeding?




 

--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joe Cheng

unread,
Jul 1, 2013, 5:37:16 PM7/1/13
to shiny-...@googlegroups.com
Oh, sorry. You're not using Shiny Server, so please disregard the previous question.

This line exists in shiny.js:
new WebSocket('ws://' + window.location.host, 'shiny')

I believe it would need to be changed to:
new WebSocket('wss://' + window.location.host, 'shiny')

Could you try this by manually changing the file on disk, just to test? You can find the location of shiny.js by using this command in R:

system.file("www/shared/shiny.js", package="shiny")

Greg Sterijevski

unread,
Jul 1, 2013, 7:41:59 PM7/1/13
to shiny-...@googlegroups.com
I have tried that. I think that I get a slew of errors on the javascript side. I will try again and post the results. Is there any way to enable a cross origin request (on the javascript side). I don't see the Origin tag anywhere is the websocket handshake.

-Greg

Joe Cheng

unread,
Jul 1, 2013, 8:36:47 PM7/1/13
to shiny-...@googlegroups.com
Hmmm. You shouldn't need cross origin, it's the same origin--same host, same port. What exactly does the exception in Opera say?

Greg Sterijevski

unread,
Jul 1, 2013, 11:35:08 PM7/1/13
to shiny-...@googlegroups.com
Here is the stack trace from Opera.

[07/01/2013 10:32:14 PM] JavaScript - https://localhost:8000/
Timeout thread: delay 4 ms
Uncaught exception: DOMException: SECURITY_ERR
Error thrown at line 453, column 8 in <anonymous function: createSocket>() in https://localhost:8000/shared/shiny.js:
    var ws = new WebSocket('ws://' + window.location.host, 'shiny');
called from line 458, column 6 in <anonymous function: createSocket>() in https://localhost:8000/shared/shiny.js:
    var socket = createSocketFunc();
called from line 438, column 6 in <anonymous function: connect>(initialInput) in https://localhost:8000/shared/shiny.js:
    this.$socket = this.createSocket();
called from line 2588, column 4 in initShiny() in https://localhost:8000/shared/shiny.js:
    shinyapp.connect(initialValues);


I am no expert on WebSockets, but my understanding is that since the request originates from https:// but is forwarded to http:// you are making a cross origin call?


-Greg

Sarven Capadisli

unread,
Jul 2, 2013, 2:32:59 AM7/2/13
to shiny-...@googlegroups.com
On 07/01/2013 11:37 PM, Joe Cheng wrote:
> Oh, sorry. You're not using Shiny Server, so please disregard the
> previous question.

If using shiny-server, how would this setup be different?

> This line exists in shiny.js:
> new WebSocket('ws://' + window.location.host, 'shiny')
>
> I believe it would need to be changed to:
> new WebSocket('wss://' + window.location.host, 'shiny')
>
> Could you try this by manually changing the file on disk, just to test?
> You can find the location of shiny.js by using this command in R:
>
> system.file("www/shared/shiny.js", package="shiny")

That doesn't work for me either.

The issue I have is that I run shiny like:

R -e "shiny::runApp('foo')"

which runs on http://localhost:8100/

There is an Apache VirtualHost for example.org with a reverse proxy:

RewriteRule ^/([^/]*)/([^/]*) ws://localhost:8100/?x=foo&y=bar [P]

When the application tries to start, it is attempting to connect to:

ws://example.org


Would it be possible to simply start the shiny application at
http://example.org/ instead of http://localhost:8100/ or is that only
possible through shiny-server?

I tried it through shiny-server in any case with this:

listen 8100;
server_name localhost;

Keeping Apache settings as is. Still no go.

I'm beginning to doubt that Apache websocket is working properly.

-Sarven

Joe Cheng

unread,
Jul 2, 2013, 11:57:41 AM7/2/13
to shiny-...@googlegroups.com
On Mon, Jul 1, 2013 at 11:32 PM, Sarven Capadisli <in...@csarven.ca> wrote:
On 07/01/2013 11:37 PM, Joe Cheng wrote:
Oh, sorry. You're not using Shiny Server, so please disregard the
previous question.

If using shiny-server, how would this setup be different?

Shiny Server uses sockjs instead of a "raw" websocket, and it tells the browser to load the sockjs JS library through an http URL. (Or it used to; this bug is fixed in our GitHub repo)


The issue I have is that I run shiny like:

R -e "shiny::runApp('foo')"

which runs on http://localhost:8100/

There is an Apache VirtualHost for example.org with a reverse proxy:

RewriteRule ^/([^/]*)/([^/]*) ws://localhost:8100/?x=foo&y=bar [P]

When the application tries to start, it is attempting to connect to:

ws://example.org

That's fine. Cross origin only applies to what the browser sees; and as far as the browser's concerned, localhost:8100 doesn't exist. The page URL is http://example.org and the websocket is at ws://example.org.


Would it be possible to simply start the shiny application at http://example.org/ instead of http://localhost:8100/ or is that only possible through shiny-server?

That would be an awful idea because it would require you to run as root. You also wouldn't be able to support SSL directly out of the R process.
 

I tried it through shiny-server in any case with this:

listen 8100;
server_name localhost;

Keeping Apache settings as is. Still no go.

I'm beginning to doubt that Apache websocket is working properly.

Can you try again but without server_name? server_name looks at the value in the Host header that comes from the browser, so that would be example.org or something. Better to just leave server_name off altogether unless you actually are running virtual hosts.

I would expect this to work because SockJS knows how to use regular HTTP requests instead of websockets if the latter fails. And since the page is coming up in the first place, it seems regular HTTP requests should work.

However you may need to install shiny-server from github, due to the old bug I mention at the top of this email:

Sarven Capadisli

unread,
Jul 2, 2013, 12:37:33 PM7/2/13
to shiny-...@googlegroups.com
On 07/02/2013 05:57 PM, Joe Cheng wrote:
>
>
>
> On Mon, Jul 1, 2013 at 11:32 PM, Sarven Capadisli <in...@csarven.ca
> <mailto:in...@csarven.ca>> wrote:
>
> On 07/01/2013 11:37 PM, Joe Cheng wrote:
>
> Oh, sorry. You're not using Shiny Server, so please disregard the
> previous question.
>
>
> If using shiny-server, how would this setup be different?
>
>
> Shiny Server uses sockjs instead of a "raw" websocket, and it tells the
> browser to load the sockjs JS library through an http URL. (Or it used
> to; this bug is fixed in our GitHub repo)
>
>
> The issue I have is that I run shiny like:
>
> R -e "shiny::runApp('foo')"
>
> which runs on http://localhost:8100/
>
> There is an Apache VirtualHost for example.org <http://example.org>
> with a reverse proxy:
>
> RewriteRule ^/([^/]*)/([^/]*) ws://localhost:8100/?x=foo&y=__bar [P]
>
> When the application tries to start, it is attempting to connect to:
>
> ws://example.org <http://example.org>
>
>
> That's fine. Cross origin only applies to what the browser sees; and as
> far as the browser's concerned, localhost:8100 doesn't exist. The page
> URL is http://example.org and the websocket is at ws://example.org
> <http://example.org>.
>
>
> Would it be possible to simply start the shiny application at
> http://example.org/ instead of http://localhost:8100/ or is that
> only possible through shiny-server?
>
>
> That would be an awful idea because it would require you to run as root.
> You also wouldn't be able to support SSL directly out of the R process.
>
>
> I tried it through shiny-server in any case with this:
>
> listen 8100;
> server_name localhost;
>
> Keeping Apache settings as is. Still no go.
>
> I'm beginning to doubt that Apache websocket is working properly.
>
>
> Can you try again but without server_name? server_name looks at the
> value in the Host header that comes from the browser, so that would be
> example.org <http://example.org> or something. Better to just leave
> server_name off altogether unless you actually are running virtual hosts.
>
> I would expect this to work because SockJS knows how to use regular HTTP
> requests instead of websockets if the latter fails. And since the page
> is coming up in the first place, it seems regular HTTP requests should work.
>
> However you may need to install shiny-server from github, due to the old
> bug I mention at the top of this email:
> sudo npm install -g https://github.com/rstudio/shiny-server/tarball/master

What you are saying is that, using shiny-server from github, it won't
bother with websockets and so it means that I should be able to use http
in my Apache rewrite and proxy?

Tried that. Also I have the git repo cloned and did:

sudo npm install -g shiny-server



Right now I have this line in my Apache VirtualHost with ServerAlias
example.org:

RewriteRule ^/([^\/]*)/([^\/]*)$
http://localhost:3838/?datasetX=$1&datasetY=$2 [P]

/usr/lib/node_modules/shiny-server/config/default.config is as is (default).

When I go to http://example.org/foo/bar I get the Index of / for
/var/shiny-server/www/

If I click on my app directory 'bbq/' it takes me to:

http://example.org/foo/bbq/

with a 404.

What am I overlooking? :)

-Sarven

Greg Sterijevski

unread,
Jul 2, 2013, 3:30:52 PM7/2/13
to shiny-...@googlegroups.com
Success!

Joe your suggestion to change the protocol to wss and a few tweaks to the NGINX config worked!! Now onto authentication!

-Greg

Joe Cheng

unread,
Jul 2, 2013, 4:03:56 PM7/2/13
to shiny-...@googlegroups.com
Oh, you just want to serve up a single Shiny app directly on the root URL; create the following config file at /etc/shiny-server/shiny-server.conf (replace the value in bold):


run_as shiny;

# The directory where application log files should be written to.
# This directory must exist--it will NOT be automatically created.
log_dir /var/shiny-server/log/;

server {
  listen 3838;

  location / {
    app_dir /path-to-your-appdir;
  }
}

Sarven Capadisli

unread,
Jul 2, 2013, 5:30:34 PM7/2/13
to shiny-...@googlegroups.com
Sort of. I simplified my example but it is actually like this:

RewriteRule ^/foo/([^\/]*)/([^\/]*)$ http://localhost:3838/?x=$1&y=$2 [P]


Now, regarding the problem. There was no:

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

but I created one. When I run shiny-server, it picks up that instead of:

/usr/lib/node_modules/shiny-server/config/default.config

The app location is:

location / {
app_dir /var/shiny-server/www/app;
}


I try to access the app with params.

http://example.org/foo/bar/baz

I get the following error for socksjs-0.3.min.js (line 27)

NetworkErorr: 404 Not Found - http://exmaple.org/foo/bar/baz__sockjs__/info



I'd like to keep /foo/ because that's just where I indicate the app as
part of the URI. It is not a physical directory.

The app directory: /var/shiny-server/www/app/ also contains a copy of
shiny JavaScript and CSS (slider, bootsrap files) if that matters. Which
seems to load fine, but I had to put a symbolik link from
/var/www/example.org/shiny to /var/shiny-server/www/app/shiny

-Sarven


On 07/02/2013 10:03 PM, Joe Cheng wrote:
> Oh, you just want to serve up a single Shiny app directly on the root
> URL; create the following config file at
> /etc/shiny-server/shiny-server.conf (replace the value in bold):
>
>
> |run_as shiny;
>
> # The directory where application log files should be written to.
> # This directory must exist--it will NOT be automatically created.
> log_dir /var/shiny-server/log/;
>
> server {
> listen 3838;
>
> location / {
> app_dir*/path-to-your-appdir;*
> }
> }
> |
>
> |
> |
>
>
> On Tue, Jul 2, 2013 at 9:37 AM, Sarven Capadisli <in...@csarven.ca
> <mailto:in...@csarven.ca>> wrote:
>
> On 07/02/2013 05:57 PM, Joe Cheng wrote:
>
>
>
>
> On Mon, Jul 1, 2013 at 11:32 PM, Sarven Capadisli
> <in...@csarven.ca <mailto:in...@csarven.ca>
> <mailto:in...@csarven.ca <mailto:in...@csarven.ca>>> wrote:
>
> On 07/01/2013 11:37 PM, Joe Cheng wrote:
>
> Oh, sorry. You're not using Shiny Server, so please
> disregard the
> previous question.
>
>
> If using shiny-server, how would this setup be different?
>
>
> Shiny Server uses sockjs instead of a "raw" websocket, and it
> tells the
> browser to load the sockjs JS library through an http URL. (Or
> it used
> to; this bug is fixed in our GitHub repo)
>
>
> The issue I have is that I run shiny like:
>
> R -e "shiny::runApp('foo')"
>
> which runs on http://localhost:8100/
>
> There is an Apache VirtualHost for example.org
> <http://example.org> <http://example.org>
> with a reverse proxy:
>
> RewriteRule ^/([^/]*)/([^/]*)
> ws://localhost:8100/?x=foo&y=____bar [P]
>
>
> When the application tries to start, it is attempting to
> connect to:
>
> ws://example.org <http://example.org> <http://example.org>
>
>
>
> That's fine. Cross origin only applies to what the browser sees;
> and as
> far as the browser's concerned, localhost:8100 doesn't exist.
> The page
> URL is http://example.org and the websocket is at
> ws://example.org <http://example.org>
> <http://example.org>.
>
>
>
> Would it be possible to simply start the shiny application at
> http://example.org/ instead of http://localhost:8100/ or is that
> only possible through shiny-server?
>
>
> That would be an awful idea because it would require you to run
> as root.
> You also wouldn't be able to support SSL directly out of the R
> process.
>
>
> I tried it through shiny-server in any case with this:
>
> listen 8100;
> server_name localhost;
>
> Keeping Apache settings as is. Still no go.
>
> I'm beginning to doubt that Apache websocket is working
> properly.
>
>
> Can you try again but without server_name? server_name looks at the
> value in the Host header that comes from the browser, so that
> would be
> example.org <http://example.org> <http://example.org> or
> something. Better to just leave
>
> server_name off altogether unless you actually are running
> virtual hosts.
>
> I would expect this to work because SockJS knows how to use
> regular HTTP
> requests instead of websockets if the latter fails. And since
> the page
> is coming up in the first place, it seems regular HTTP requests
> should work.
>
> However you may need to install shiny-server from github, due to
> the old
> bug I mention at the top of this email:
> sudo npm install -g
> https://github.com/rstudio/__shiny-server/tarball/master
> <https://github.com/rstudio/shiny-server/tarball/master>
>
>
> What you are saying is that, using shiny-server from github, it
> won't bother with websockets and so it means that I should be able
> to use http in my Apache rewrite and proxy?
>
> Tried that. Also I have the git repo cloned and did:
>
> sudo npm install -g shiny-server
>
>
>
> Right now I have this line in my Apache VirtualHost with ServerAlias
> example.org <http://example.org>:
>
> RewriteRule ^/([^\/]*)/([^\/]*)$
> http://localhost:3838/?__datasetX=$1&datasetY=$2
> <http://localhost:3838/?datasetX=$1&datasetY=$2> [P]
>
> /usr/lib/node_modules/shiny-__server/config/default.config is as is
> (default).
>
> When I go to http://example.org/foo/bar I get the Index of / for
> /var/shiny-server/www/
>
> If I click on my app directory 'bbq/' it takes me to:
>
> http://example.org/foo/bbq/
>
> with a 404.
>
> What am I overlooking? :)
>
> -Sarven
>
>

Joe Cheng

unread,
Jul 2, 2013, 6:56:42 PM7/2/13
to shiny-...@googlegroups.com
http://exmaple.org/foo/bar/baz__sockjs__/info

This *must* be


and consequently, I think the original http://example.org/foo/bar/baz needs to redirect itself to http://example.org/foo/bar/baz/ at the Apache level.

You may have to tweak your mod_rewrite directives a bit to make this work, but there should be plenty of pointers on google as needing to automatically add a trailing slash is a pretty common issue in these proxying situations.


Sarven Capadisli

unread,
Jul 3, 2013, 5:45:03 AM7/3/13
to shiny-...@googlegroups.com
I can get it to work in two ways [1] [2] but they both give an error in
Firebug. The application appears to work fine, but it gives two errors:

"NetworkError: 400 Bad Request -
http://example.org/foo/bar/baz/__sockjs__/439/i_dq8bcz/websocket"

Firefox can't establish a connection to the server at
ws://example.org/foo/bar/baz/__sockjs__/439/i_dq8bcz/websocket.

As I understood the use of sockjs in shiny-server was that it was in
place of raw websockets as you put it, so why the errors and should they
be eliminated? Perhaps my rewrites are not quite right.


[1] With trailing slash redirect:
RewriteRule ^/foo/([^\/]*)/([^\/]*)$ foo/$1/$2/ [R,L]
RewriteRule ^/foo/([^\/]*)/([^\/]*)/_(.*)$ http://localhost:3838/_$4 [P,L]
RewriteRule ^/foo/([^\/]*)/([^\/]*)/$ http://localhost:3838/?x=$1&y=$2 [P]


[2] Without trailing slash redirect:
RewriteRule ^/foo/([^\/]*)/([^\_]*)(.*)$ http://localhost:3838/$3 [P]
RewriteRule ^/foo/([^\/]*)/([^\/]*)$ http://localhost:3838/?x=$1&y=$2 [P]


-Sarven

On 07/03/2013 12:56 AM, Joe Cheng wrote:
> http://exmaple.org/foo/bar/baz__sockjs__/info
>
> This *must* be
>
> http://exmaple.org/foo/bar/baz/__sockjs__/info
>
> and consequently, I think the original http://example.org/foo/bar/baz
> needs to redirect itself to http://example.org/foo/bar/baz/ at the
> Apache level.
>
> You may have to tweak your mod_rewrite directives a bit to make this
> work, but there should be plenty of pointers on google as needing to
> automatically add a trailing slash is a pretty common issue in these
> proxying situations.
>
>
> On Tue, Jul 2, 2013 at 2:30 PM, Sarven Capadisli <in...@csarven.ca
> <mailto:in...@csarven.ca>> wrote:
>
> Sort of. I simplified my example but it is actually like this:
>
> RewriteRule ^/foo/([^\/]*)/([^\/]*)$
> http://localhost:3838/?x=$1&y=__$2
> <http://localhost:3838/?x=$1&y=$2> [P]
>
>
> Now, regarding the problem. There was no:
>
> /etc/shiny-server/shiny-__server.conf
>
> but I created one. When I run shiny-server, it picks up that instead of:
>
> /usr/lib/node_modules/shiny-__server/config/default.config
>
> The app location is:
>
> location / {
> app_dir /var/shiny-server/www/app;
> }
>
>
> I try to access the app with params.
>
> http://example.org/foo/bar/baz
>
> I get the following error for socksjs-0.3.min.js (line 27)
>
> NetworkErorr: 404 Not Found -
> http://exmaple.org/foo/bar/__baz__sockjs__/info
> <http://exmaple.org/foo/bar/baz__sockjs__/info>
>
>
>
> I'd like to keep /foo/ because that's just where I indicate the app
> as part of the URI. It is not a physical directory.
>
> The app directory: /var/shiny-server/www/app/ also contains a copy
> of shiny JavaScript and CSS (slider, bootsrap files) if that
> matters. Which seems to load fine, but I had to put a symbolik link
> from /var/www/example.org/shiny <http://example.org/shiny> to
> /var/shiny-server/www/app/__shiny
>
> -Sarven
>
>
>
> On 07/02/2013 10:03 PM, Joe Cheng wrote:
>
> Oh, you just want to serve up a single Shiny app directly on the
> root
> URL; create the following config file at
> /etc/shiny-server/shiny-__server.conf (replace the value in bold):
>
>
> |run_as shiny;
>
> # The directory where application log files should be written to.
> # This directory must exist--it will NOT be automatically created.
> log_dir /var/shiny-server/log/;
>
> server {
> listen 3838;
>
> location / {
> app_dir*/path-to-your-appdir;*
>
> }
> }
> |
>
> |
> |
>
>
> On Tue, Jul 2, 2013 at 9:37 AM, Sarven Capadisli
> <in...@csarven.ca <mailto:in...@csarven.ca>
> ws://localhost:8100/?x=foo&y=______bar [P]
> https://github.com/rstudio/____shiny-server/tarball/master
> <https://github.com/rstudio/__shiny-server/tarball/master>
>
>
> <https://github.com/rstudio/__shiny-server/tarball/master
> <https://github.com/rstudio/shiny-server/tarball/master>>
>
>
> What you are saying is that, using shiny-server from github, it
> won't bother with websockets and so it means that I should
> be able
> to use http in my Apache rewrite and proxy?
>
> Tried that. Also I have the git repo cloned and did:
>
> sudo npm install -g shiny-server
>
>
>
> Right now I have this line in my Apache VirtualHost with
> ServerAlias
> example.org <http://example.org> <http://example.org>:
>
>
> RewriteRule ^/([^\/]*)/([^\/]*)$
> http://localhost:3838/?____datasetX=$1&datasetY=$2
> /usr/lib/node_modules/shiny-____server/config/default.config is
> as is
>
> (default).
>
> When I go to http://example.org/foo/bar I get the Index of
> / for
> /var/shiny-server/www/
>
> If I click on my app directory 'bbq/' it takes me to:
>
> http://example.org/foo/bbq/
>
> with a 404.
>
> What am I overlooking? :)
>
> -Sarven
>
>
> --
> 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-discuss+unsubscribe@__googlegroups.com
> <mailto:shiny-discuss%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
>
> --
> 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.

Joe Cheng

unread,
Jul 3, 2013, 11:22:14 AM7/3/13
to shiny-...@googlegroups.com
I don't think apache knows how to proxy websockets. But sockjs is supposed to fall back to a different transport if websockets fail. Is that what you're seeing? Does the app work despite the error?
--
Sent from my phone

Sarven Capadisli

unread,
Jul 3, 2013, 11:29:48 AM7/3/13
to shiny-...@googlegroups.com
What I'm seeing is the errors I listed. Yes, the application appears to
work fine regardless.

This email thread contains all the information in my setup. I will look
the other way for the time being, and proceed with the application -
will post back if I experience something else.

Thank you for all the follow ups. Much helpful!

On 07/03/2013 05:22 PM, Joe Cheng wrote:
> I don't think apache knows how to proxy websockets. But sockjs is
> supposed to fall back to a different transport if websockets fail. Is
> that what you're seeing? Does the app work despite the error?
>
> On Wednesday, July 3, 2013, Sarven Capadisli wrote:
>
> I can get it to work in two ways [1] [2] but they both give an error
> in Firebug. The application appears to work fine, but it gives two
> errors:
>
> "NetworkError: 400 Bad Request -
> http://example.org/foo/bar/__baz/__sockjs__/439/i_dq8bcz/__websocket
> <http://example.org/foo/bar/baz/__sockjs__/439/i_dq8bcz/websocket>"
>
> Firefox can't establish a connection to the server at
> ws://example.org/foo/bar/baz/____sockjs__/439/i_dq8bcz/__websocket
> <http://example.org/foo/bar/baz/__sockjs__/439/i_dq8bcz/websocket>.
>
> As I understood the use of sockjs in shiny-server was that it was in
> place of raw websockets as you put it, so why the errors and should
> they be eliminated? Perhaps my rewrites are not quite right.
>
>
> [1] With trailing slash redirect:
> RewriteRule ^/foo/([^\/]*)/([^\/]*)$ foo/$1/$2/ [R,L]
> RewriteRule ^/foo/([^\/]*)/([^\/]*)/_(.*)$ http://localhost:3838/_$4
> [P,L]
> RewriteRule ^/foo/([^\/]*)/([^\/]*)/$
> [2] Without trailing slash redirect:
> RewriteRule ^/foo/([^\/]*)/([^\_]*)(.*)$ http://localhost:3838/$3 [P]
> RewriteRule ^/foo/([^\/]*)/([^\/]*)$
> -Sarven
>
> On 07/03/2013 12:56 AM, Joe Cheng wrote:
>
> http://exmaple.org/foo/bar/__baz__sockjs__/info
> http://exmaple.org/foo/bar/__baz/__sockjs__/info
> <http://exmaple.org/foo/bar/baz/__sockjs__/info>
>
> and consequently, I think the original
> http://example.org/foo/bar/baz
> needs to redirect itself to http://example.org/foo/bar/__baz/
> <http://example.org/foo/bar/baz/> at the
> Apache level.
>
> You may have to tweak your mod_rewrite directives a bit to make this
> work, but there should be plenty of pointers on google as needing to
> automatically add a trailing slash is a pretty common issue in these
> proxying situations.
>
>
> On Tue, Jul 2, 2013 at 2:30 PM, Sarven Capadisli <in...@csarven.ca
> <mailto:in...@csarven.ca>> wrote:
>
> Sort of. I simplified my example but it is actually like this:
>
> RewriteRule ^/foo/([^\/]*)/([^\/]*)$
> http://localhost:3838/?x=$1&y=____$2
> <http://localhost:3838/?x=$1&y=__$2>
> <http://localhost:3838/?x=$1&__y=$2
> <http://localhost:3838/?x=$1&y=$2>> [P]
>
>
> Now, regarding the problem. There was no:
>
> /etc/shiny-server/shiny-____server.conf
>
> but I created one. When I run shiny-server, it picks up
> that instead of:
>
> /usr/lib/node_modules/shiny-____server/config/default.config
>
> The app location is:
>
> location / {
> app_dir /var/shiny-server/www/app;
> }
>
>
> I try to access the app with params.
>
> http://example.org/foo/bar/baz
>
> I get the following error for socksjs-0.3.min.js (line 27)
>
> NetworkErorr: 404 Not Found -
> http://exmaple.org/foo/bar/____baz__sockjs__/info
> <http://exmaple.org/foo/bar/__baz__sockjs__/info>
> <http://exmaple.org/foo/bar/__baz__sockjs__/info
> <http://exmaple.org/foo/bar/baz__sockjs__/info>>
>
>
>
> I'd like to keep /foo/ because that's just where I indicate
> the app
> as part of the URI. It is not a physical directory.
>
> The app directory: /var/shiny-server/www/app/ also contains
> a copy
> of shiny JavaScript and CSS (slider, bootsrap files) if that
> matters. Which seems to load fine, but I had to put a
> symbolik link
> from /var/www/example.org/shiny <http://example.org/shiny>
> <http://example.org/shiny> to
> /var/shiny-server/www/app/____shiny
>
> -Sarven
>
>
>
> On 07/02/2013 10:03 PM, Joe Cheng wrote:
>
> Oh, you just want to serve up a single Shiny app
> directly on the
> root
> URL; create the following config file at
> /etc/shiny-server/shiny-____server.conf (replace the
> ws://localhost:8100/?x=foo&y=________bar [P]
> https://github.com/rstudio/______shiny-server/tarball/master
> <https://github.com/rstudio/____shiny-server/tarball/master>
>
> <https://github.com/rstudio/____shiny-server/tarball/master
> <https://github.com/rstudio/__shiny-server/tarball/master>>
>
>
>
> <https://github.com/rstudio/____shiny-server/tarball/master
> <https://github.com/rstudio/__shiny-server/tarball/master>
>
> <https://github.com/rstudio/__shiny-server/tarball/master
> <https://github.com/rstudio/shiny-server/tarball/master>>>
>
>
> What you are saying is that, using shiny-server
> from github, it
> won't bother with websockets and so it means that
> I should
> be able
> to use http in my Apache rewrite and proxy?
>
> Tried that. Also I have the git repo cloned and did:
>
> sudo npm install -g shiny-server
>
>
>
> Right now I have this line in my Apache
> VirtualHost with
> ServerAlias
> example.org <http://example.org> <http://example.org>
> <http://example.org>:
>
>
> RewriteRule ^/([^\/]*)/([^\/]*)$
> http://localhost:3838/?______datasetX=$1&datasetY=$2
> /usr/lib/node_modules/shiny-______server/config/default.config is
> as is
>
> (default).
>
> When I go to http://example.org/foo/bar I get the
> Index of
> / for
> /var/shiny-server/www/
>
> If I click on my app directory 'bbq/' it takes me to:
>
> http://example.org/foo/bbq/
>
> with a 404.
>
> What am I overlooking? :)
>
> -Sarven
>
>
> --
> 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-discuss+unsubscribe@__go__oglegroups.com
> <http://googlegroups.com>
> <mailto:shiny-discuss%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/____groups/opt_out
> <https://groups.google.com/__groups/opt_out>
> <https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>>.
>
>
>
>
>
> --
> 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.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
>
>
> --
> Sent from my phone
Reply all
Reply to author
Forward
0 new messages