Get nodebb working with virtual host and sub directory on apache2.4

  • administrators

    One of the first issues I ran into getting nodebb working was getting it to play nice with my virtual host on apache. If you look at the documentation most of what you need is already there, but I wanted to get it working with my existing virtual host so I had to tweak it a bit.

    here is the relevant code for apache:

    <VirtualHost *:80>
    ServerAlias *
    ProxyRequests Off
    ProxyVia Off
    <Proxy *>
            Order deny,allow
            Allow from all
    # edit the next line if you use https
    RequestHeader set X-Forwarded-Proto "http"
    RewriteEngine On
    AllowEncodedSlashes On #important for the admin interface on nodebb
    RewriteCond %{REQUEST_URI}  ^/forum/            [NC]
    RewriteCond %{QUERY_STRING} transport=websocket    [NC]
    RewriteRule /forum/(.*)           ws://$1 [P,L]
    ProxyPass /forum/ nocanon
    ProxyPassReverse /forum/
    DocumentRoot /mydocroot #where the rest of the site lives

    The only real differences between this and the documentation are 'AllowEncodedSlashes On' which is necessary to get the admin interface working. and I have appended the '/' with '/forum/' to make only the forum sub directory reverse proxied.

    Next, to get the sub directory working you need to change your nodebb config.json file to the following:

        "url": "",
        "secret": "itsasecret",
        "database": "mongo",
        "port": "4567",
        "mongo": {
            "host": "",
            "port": "27017",
            "username": "xxx",
            "password": "xxx",
            "database": "xxx"

    I'm ashamed to say how long it took me to figure this out, but as you can see its working now.



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