input-output-hk / cardano-rt-view

RTView: real-time watching for Cardano nodes (ARCHIVED)
Apache License 2.0
59 stars 11 forks source link

Access/Serve RT View using non-root URI #74

Open pferdob opened 4 years ago

pferdob commented 4 years ago

I used RT View for some days now, server from http://cardano.domain.com. In order to be able to use Let's Encrypt's cerbot for https (which includes serving static "challenge" files to show one is the owner of the domain in question), I want to move RT View from / to /rt-view/ in nginx' configuration (ergo http://cardano.domain.com/rt-view).

Previous nginx config:

location / {
    auth_basic           "Cardano RT View Authorization";
    auth_basic_user_file /etc/nginx/conf.d/.htpasswd-cardano-rt-view;
    proxy_pass           http://127.0.0.1:8024/;
}

Resulting HTTP headers:

[...]
--> http://cardano.domain.com:80/haskell.js
<-- GET: HTTP/1.1 200 OK
--> ws://cardano.domain.com:80/websocket/
<-- GET: HTTP/1.1 101 WebSocket Protocol Handshake
[...]

Until here everything works as expected.

New nginx config:

root         /srv/www/cardano.domain.com/html;
index        index.html;
location / {
    try_files            $uri $uri/ =404;
}
location /rt-view/ {
    auth_basic           "Cardano RT View Authorization";
    auth_basic_user_file /etc/nginx/conf.d/.htpasswd-cardano-rt-view;
    proxy_pass           http://127.0.0.1:8024/;
}

HTTP headers:

[...]
--> http://cardano.domain.com:80/rt-view/haskell.js
<-- GET: HTTP/1.1 200 OK
--> ws://cardano.domain.com:80/websocket/
<-- NS_ERROR_CONNECTION_REFUSED
[...]

I've tried quite some configuration work-arounds, rewrites, added the same rules for location /websocket/ etc. but it seems that only a proper request might help here? As I'm no expert in nginx configuration I might be missing sth. as well...

OS:      Fedora 33 Server
RT View: 0.1.0
Nginx:   1.18.0

Thanks in advance

denisshevchenko commented 4 years ago

As I'm no expert in nginx configuration...

Sorry, I'm not an expert in nginx as well. I've tried only the simplest configuration (with location /). But probably I have to try it by myself (because your scenario may be actual for other users as well, I'm not sure).

I can't promise you that I'll do it very soon...

pferdob commented 4 years ago

I guess it would be reasonable to assume nginx expects a request of ws://cardano.domain.com:80/rt-view/websocket/. How else is it supposed to know to location this websocket belongs? I guess it is part of the scripts delivered by the internal web server. One cannot really try it out unless fixing them for using the whole URI instead of the hostname only.

Thank you!