My knowledge of Varnish is very limited - but don't you have to either pipe Varnish into nginx and then NodeBB or nginx into Varnish and then NodeBB? From your configuration, it seems you're trying to pipe nginx into NodeBB on port 2000 and the same for Varnish. Can Varnish and nginx coexist on the same port?
Here is my working configuration but against, I'm running nginx to Varnish's default port (e.g., 6081).
server {
listen 80;
server_name domain.com *.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:6081/;
#proxy_pass http://127.0.0.1:4567/;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
For Varnish, I'm just using the default instructions. RHEL 6.5 as well.