Apache reverse proxy, subfolder, and websockets



  • I'm currently testing NodeBB (1.0.3). I wanted to setup NodeBB on a test installation in a subfolder. Seemed to work quite fine until I ran into troubles with the administration page. For some reasons I never managed to load the dashboard traffic graph. Looking at the network traffic it seemed that the websocket connection was kind of unreliable. Sometimes it worked, sometimes it didn't.

    My config.json:

    {
        "url": "http://localhost:8080/tf1",
        "port": 4567,
        "secret": "f045d8a3-d438-4a37-8a6f-aacbbeddf0ce",
        "database": "mongo",
        "mongo": {
            "host": "127.0.0.1",
            "port": "27017",
            "username": "nodebb",
            "password": "nodebb",
            "database": "nodebb"
        }
    }
    

    And my apache configuration:

    <VirtualHost *:80>
        ServerName nodebb.localhost
        DocumentRoot /var/www/html
    
        ProxyRequests off
    
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
    
        RewriteEngine On
    
        RewriteCond %{REQUEST_URI}  ^/tf1/socket.io            [NC]
        RewriteCond %{QUERY_STRING} transport=websocket        [NC]
        RewriteRule /tf1/(.*)       ws://localhost:4567/tf1/$1 [P,L]
    
        ProxyPass /tf1/ http://localhost:4567/tf1/
        ProxyPassReverse /tf1/ http://localhost:4567/tf1/
    </VirtualHost>
    

    NodeBB and the Apache server are running in a virtual machine attached through a NAT with port forwarding on the localhost of the host machine. Port forwarding is setup for host:8080 to guest:80.

    The forum itself seemed to work fine. Also for example the Manage->Categories loaded all categories fine. But the dashboard didn't wanted to load. I tested it in the latest Firefox (46.0.1) and latest stable Vivaldi (1.1.453.59). When I looked at the network overview from the Chrome Developer Tools in Vivaldi, I saw that some things were loaded through the websockets. But sometimes it seems there were timeouts or something like that: (Opcode -1).

    When I removed the "/tf1" subfolder everything worked fine. Any help would be appreciated.



  • Short update:

    I further analyzed this. Apparently there are at least two different problems. I'm getting a websocket connection abort, something about an invalid frame header in acp.js. This part I'm not much further as of yet.

    The other thing is a problem with loading some Javascript files. For example Chart.js and mousetrap.js. Quite interestingly those are files that aren't provided in the public directory but instead are coming from node_modules. The ones in the public directory are being loaded correctly.



  • Well, after that post I went digging in the code. And look what I found:
    https://github.com/NodeBB/nodebb-plugin-composer-default/issues/37
    https://github.com/NodeBB/NodeBB/pull/4621

    That actually fixes my issues. I updated to weekly and everything seems to work nicely. Seems to have also fixed the problem with the websockets. I see no more errors. When can we expect the v1.0.4? :)


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.