Unable to login

Technical Support
  • I have dockerized existing Nodebb installation, transfered db to docker container too. Threads are shown correctly but I can't login at all - nodebb.example.com/login returns "Forbidden".

    In front of nodebb there is reverse proxy. I get following errors when trying to login:
    0_1493883059427_Screenshot from 2017-04-20 13_31_28.png
    0_1493883071114_Screenshot from 2017-04-20 13_31_44.png

    / # npm -v
    4.4.4
    / # node --version
    v7.9.0
    
    

    Log

    app_1      | NodeBB v1.1.2 Copyright (C) 2013-2014 NodeBB Inc.
    app_1      | This program comes with ABSOLUTELY NO WARRANTY.
    app_1      | This is free software, and you are welcome to redistribute it under certain conditions.
    app_1      | For the full license, please visit: http://www.gnu.org/copyleft/gpl.html
    app_1      | 
    app_1      | Clustering enabled: Spinning up 1 process(es).
    app_1      | 
    app_1      | 4/5 06:57 [21] - verbose: * using configuration stored in: /opt/nodebb/NodeBB-1.1.2/config.json
    app_1      | 4/5 06:57 [21] - info: Time: Thu May 04 2017 06:57:39 GMT+0000 (UTC)
    app_1      | 4/5 06:57 [21] - info: Initializing NodeBB v1.1.2
    app_1      | 4/5 06:57 [21] - verbose: * using mongo store at mongodb:27017
    app_1      | 4/5 06:57 [21] - verbose: * using themes stored in: /opt/nodebb/NodeBB-1.1.2/node_modules
    app_1      | 4/5 06:57 [21] - info: [database] Checking database indices.
    app_1      | 4/5 06:57 [21] - verbose: Checking dependencies for outdated modules
    app_1      | 4/5 06:57 [21] - verbose: [notifications.init] Registering jobs.
    app_1      | 4/5 06:57 [21] - info: [themes] Using theme nodebb-theme-persona
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Initializing plugins system
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 5 js file(s) for plugin nodebb-theme-persona
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-theme-persona/lib/persona.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-theme-persona/lib/modules/nprogress.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-theme-persona/lib/modules/autohidingnavbar.min.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-theme-persona/lib/modules/slideout.min.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-theme-persona/lib/client/chats.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 ACP js file(s) for plugin nodebb-theme-persona
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-theme-persona/lib/admin.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-theme-persona
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-composer-default
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 2 js file(s) for plugin nodebb-plugin-composer-default
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-plugin-composer-default/static/lib/client.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File not found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-plugin-composer-default/node_modules/screenfull/dist/screenfull.js (Ascending)
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/screenfull/dist/screenfull.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 ACP js file(s) for plugin nodebb-plugin-composer-default
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-plugin-composer-default/static/lib/admin.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 10 AMD-style module(s) for plugin nodebb-plugin-composer-default
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-plugin-composer-default
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-markdown
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-markdown
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-plugin-markdown/public/js/client.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 ACP js file(s) for plugin nodebb-plugin-markdown
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-plugin-markdown/public/js/admin.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 AMD-style module(s) for plugin nodebb-plugin-markdown
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-plugin-markdown
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-mentions
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-mentions
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-plugin-mentions/static/autofill.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-plugin-mentions
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 css file(s) for plugin nodebb-widget-essentials
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-widget-essentials
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-rewards-essentials
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-rewards-essentials/static/lib/main.js
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-rewards-essentials
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-plugin-soundpack-default
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-emoji-extended
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-emoji-extended
    app_1      | 4/5 06:57 [21] - verbose: [plugins/load] File found: /opt/nodebb/NodeBB-1.1.2/node_modules/nodebb-plugin-emoji-extended/public/scripts/
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-plugin-emoji-extended
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-plugin-emoji-one
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loaded plugin: nodebb-plugin-dbsearch
    app_1      | 4/5 06:57 [21] - info: [plugins] Plugins OK
    app_1      | 4/5 06:57 [21] - verbose: [meta/js] 14 of 14 modules bridged
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loading templates (nodebb-theme-persona)
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loading templates (nodebb-plugin-composer-default)
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loading templates (nodebb-plugin-markdown)
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loading templates (nodebb-widget-essentials)
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loading templates (nodebb-plugin-emoji-extended)
    app_1      | 4/5 06:57 [21] - verbose: [plugins] Loading templates (nodebb-plugin-dbsearch)
    app_1      | 4/5 06:57 [21] - verbose: [meta/templates] Compiling templates
    app_1      | 4/5 06:57 [21] - verbose: [meta/templates] Successfully compiled templates.
    app_1      | 4/5 06:57 [21] - verbose: [meta/js] Minifying nodebb.min.js
    app_1      | [minifier] file not found, node_modules/socket.io-client/socket.io.js
    app_1      | 4/5 06:57 [21] - verbose: [meta/js] nodebb.min.js minification complete
    app_1      | 4/5 06:57 [21] - verbose: [meta/js] Minifying acp.min.js
    app_1      | [minifier] file not found, node_modules/socket.io-client/socket.io.js
    app_1      | 4/5 06:57 [21] - verbose: [meta/js] acp.min.js minification complete
    app_1      | 4/5 06:57 [21] - verbose: [meta/css] Minifying LESS/CSS
    app_1      | 4/5 06:57 [21] - verbose: [meta/css] stylesheet.css committed to disk.
    app_1      | 4/5 06:57 [21] - verbose: [meta/css] admin.css committed to disk.
    app_1      | 4/5 06:57 [21] - info: NodeBB Ready
    app_1      | 4/5 06:57 [21] - info: Enabling 'trust proxy'
    app_1      | 4/5 06:57 [21] - info: NodeBB is now listening on: 0.0.0.0:4567
    app_1      | 4/5 06:57 [21] - verbose: [sounds] Sounds OK
    app_1      | 4/5 06:57 [21] - verbose: [meta/blacklist] Loading 0 blacklist rules
    app_1      | 4/5 06:57 [21] - verbose: [hotswap] Router with id `plugins` replaced successfully
    app_1      | 4/5 06:57 [21] - verbose: [plugins] All plugins reloaded and rerouted
    app_1      | 4/5 06:57 [21] - verbose: [hotswap] Router with id `auth` replaced successfully
    app_1      | 4/5 06:58 [21] - warn: Route requested but not found: /customHP
    app_1      | 4/5 06:58 [21] - warn: Route requested but not found: /customHP
    app_1      | 4/5 06:58 [21] - error: /login
    app_1      |  invalid csrf token
    
    

    config.json

    {
        "url": "https://nodebb.example.com",
        "secret": "xxxxxxxxxxxxxx",
        "database": "mongo",
        "port": 4567,
        "mongo": {
            "host": "mongodb",
            "port": "27017",
            "username": "xxxxx",
            "password": "xxxxx",
            "database": "nodebb"
        },
        "socket.io": {
            "transports": ["websocket", "polling"],
            "address": "nodebb.example.com"
        }
    }
    

    Dockerfile

    FROM mhart/alpine-node:4
    ENV NODEBB_VERSION 1.1.2
    
    RUN mkdir -p /opt/nodebb \
     && addgroup nodebb \
     && adduser -S -G nodebb -h /opt/nodebb -D nodebb \
     && chown -R nodebb:nodebb /opt/nodebb
    RUN apk --update add curl
    
    USER nodebb
    
    RUN cd /opt/nodebb \
     && curl -L https://github.com/NodeBB/NodeBB/archive/v${NODEBB_VERSION}.tar.gz -o v${NODEBB_VERSION}.tar.gz \
     && tar xzf v${NODEBB_VERSION}.tar.gz 
     
    RUN cd /opt/nodebb/NodeBB-${NODEBB_VERSION} && npm install --production
    
    VOLUME ["/opt/nodebb/NodeBB-${NODEBB_VERSION}/public/uploads"]
    CMD ["/bin/sh", "-c", "cd /opt/nodebb/NodeBB-${NODEBB_VERSION} && node app"]
    EXPOSE 4567
    
    

    Containers are setup with docker-compose, separate container for nodebb and database. Nodebb container is started with command: ["/bin/sh", "-c", "cd /opt/nodebb/NodeBB-1.1.2/ && ./nodebb dev"]

    nginx conf

    # If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
    # scheme used to connect to this server
    map $http_x_forwarded_proto $proxy_x_forwarded_proto {
      default $http_x_forwarded_proto;
      ''      $scheme;
    }
    # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
    # server port the client connected to
    map $http_x_forwarded_port $proxy_x_forwarded_port {
      default $http_x_forwarded_port;
      ''      $server_port;
    }
    # If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
    # Connection header that may have been passed to this server
    map $http_upgrade $proxy_connection {
      default upgrade;
      '' close;
    }
    # Set appropriate X-Forwarded-Ssl header
    map $scheme $proxy_x_forwarded_ssl {
      default off;
      https on;
    }
    gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    log_format vhost '$host $remote_addr - $remote_user [$time_local] '
                     '"$request" $status $body_bytes_sent '
                     '"$http_referer" "$http_user_agent"';
    access_log off;
    # HTTP 1.1 support
    proxy_http_version 1.1;
    proxy_buffering off;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $proxy_connection;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
    proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
    proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
    # Mitigate httpoxy attack (see README for details)
    proxy_set_header Proxy "";
    server {
        server_name _; # This is just an invalid value which will never trigger on a real hostname.
        listen 80;
        access_log /var/log/nginx/access.log vhost;
        return 503;
    }
    
    # nodebb.example.com
    upstream nodebb.example.com {
            ## Can be connect with "back" network
          # nodebb_app_1
          #docker container IP
          server 172.21.0.2:4567;
    }
    server {
      server_name nodebb.example.com.com;
      listen 80 ;
      access_log /var/log/nginx/access.log vhost;
      return 301 https://$host$request_uri;
    }
    server {
      server_name nodebb.example.com;
      listen 443 ssl http2 ;
      access_log /var/log/nginx/access.log vhost;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AE
    S128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-
    SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-
    SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
      ssl_prefer_server_ciphers on;
        ssl_session_timeout 5m;
        ssl_session_cache shared:SSL:50m;
        ssl_session_tickets off;
        ssl_certificate /etc/nginx/certs/nodebb.example.com.crt;
        ssl_certificate_key /etc/nginx/certs/nodebb.example.com.key;
        ssl_dhparam /etc/nginx/certs/nodebb.example.com.dhparam.pem;
        add_header Strict-Transport-Security "max-age=31536000";
        include /etc/nginx/vhost.d/default;
        location / {
          proxy_pass http://nodebb.example.com;
        }
      }
    
    
  • Any ideas? I tried installing older version of socket.io (1.4.8 instead of 1.7.1), made no difference.

  • Minifier is showing that it can't find some of the socket.io files. Make sure all of the dependencies are installed correctly (npm i --production)... perhaps try nuking node_modules/ and trying again?


Suggested Topics