plankanban / planka

The realtime kanban board for workgroups built with React and Redux.
https://planka.app
GNU Affero General Public License v3.0
7.8k stars 727 forks source link

When I change to use domain, it load forever #189

Open cmdntd opened 2 years ago

cmdntd commented 2 years ago

I try to change to sub-domain, and use reserve proxy from docker It load forever at first black status page.

My error

WebSocket connection to 'wss://sub.domain.net/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed:

Could you check this, please?

devSparkle commented 2 years ago

I experienced this issue while setting up my instance too. Did you change the BASE_URL environment variable to the browsable subdomain, in your Planka docker configuration?

cmdntd commented 2 years ago

Yes. I changed it.

BASE_URL=https://sub.mydomain.net
TRUST_PROXY=0

Then I tried to change TRUST_PROXY=1, it has the same issuse.

Coud I use SSL here?

devSparkle commented 2 years ago

What kind of proxy are you setting up? In my case I was using NGINX, which requires the following headers be setup to function as a WebSocket proxy:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
cmdntd commented 2 years ago

I use openlitespeed, and reserve proxy for docker

3615alexis commented 2 years ago

Hello, I have the same issue here :

In Chrome :

WebSocket connection to 'wss://subdomain.domain.com/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: 

In Firefox :

GET wss://subdomain.domain.com/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket
[[HTTP/1.1 403 Forbidden 43ms]]()

On the contrary there is no error if I put BASE_URL=http://MY.LOCAL.IP:3000 (but I can't benefit from my domain)

Could this be linked to some config files, for instance server/config/env/production.js where we can declare 'onlyAllowOrigins' on websites allowed to open socket connections ? Could this be configurable from docker-compose.yml ?

sockets: {
    /**
     *
     * Uncomment the `onlyAllowOrigins` whitelist below to configure which
     * "origins" are allowed to open socket connections to your Sails app.
     *
     * > Replace "https://example.com" etc. with the URL(s) of your app.
     * > Be sure to use the right protocol!  ("http://" vs. "https://")
     *
     */

    onlyAllowOrigins: [
        new url.URL(process.env.BASE_URL).origin
    ],

Thanks for your help

3615alexis commented 2 years ago

Finally I made it work ! It was linked to a bad management of SSL for WebSocket protocol.

I ended up having this in my "docker-compose.yml":

environment:
      - BASE_URL=https://subdomain.domain.com
      - TRUST_PROXY=1

And I have this in my Apache conf (the RewriteCond in "location /" did make the trick) :

<VirtualHost *:80>
    ServerName subdomain.domain.com

    Redirect permanent / https://subdomain.domain.com/
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =subdomain.domain.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>
<VirtualHost *:443>
    ServerName subdomain.domain.com

    Protocols h2 http/1.1

    SSLEngine On

    <Directory />
      Options -Indexes +FollowSymlinks
      AllowOverride None
      Require all granted
    </Directory>

    ProxyRequests On
    ProxyVia Full
    <Proxy *>
    Require all granted
    </Proxy>

    <Location />
        ProxyPass http://MY.LOCAL.IP:3000/
        ProxyPassReverse http://MY.LOCAL.IP:3000/
        **RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
        RewriteRule /socket.io/(.*) ws://MY.LOCAL.IP:3000/socket.io/$1 [P]**
    </Location>
</VirtualHost>