Site is not working properly with nginx proxy?



  • Hey guys, so I have decided to try NodeBB yesterday but I got lots of issues with the rules and i'm fairly good with nginx and servers but i don't know what's wrong.

    Here's full issue details:
    Site public folder path: /home/nginx/domains/mydomain/public
    NodeBB path: /home/nginx/domains/mydomain/ (I installed it here in hope the issue would be solved)

    First I installed it in a sub folder but I got lots off issues where CSS and JS files didn't load for some reason even after adding the rules.

    When I moved it to the path mentioned above the CSS is restored but the JS files won't work I inspected the network traffic and it show's 404 for most files.

    I have to note the site is working good with the normal server ip and port 0.0.0.0:4567.

    Any idea why would this happen?



  • @Cyb3r If it's working properly from localhost:port, then NodeBB isn't the problem. The installation paths are not going to matter either. NodeBB is serving the CSS, etc, itself. In my config, nginx has no idea where the files are coming from, just the port to which it passes the request.

    That means that your nginx config is incorrect. So, post it and let's see what's going on.

    Good luck.



  • @Cyb3r Sounds like you have your Nginx webserver looking at the installation paths as you would with a traditional HTML based web site. NodeBB does not work like that. You need to setup a reverse proxy from Nginx to the NodeBB software listening, by default, on port 4567.

    Take a look at this document regarding how you may setup your Nginx to proxy for NodeBB:

    https://docs.nodebb.org/en/latest/configuring/proxies/nginx.html

    Good luck.



  • @tqwhite said in Site is not working properly with nginx proxy?:

    @Cyb3r If it's working properly from localhost:port, then NodeBB isn't the problem. The installation paths are not going to matter either. NodeBB is serving the CSS, etc, itself. In my config, nginx has no idea where the files are coming from, just the port to which it passes the request.

    That means that your nginx config is incorrect. So, post it and let's see what's going on.

    Good luck.

    Thanks for the reply and here's my nginx config:

    server {
    	server_name mydomain;
    
    	access_log /home/nginx/domains/mydomain/log/access.log combined buffer=256k flush=60m;
    	error_log /home/nginx/domains/mydomain/log/error.log;
    
    	root /home/nginx/domains/mydomain/public;
    
    	# prevent access to ./directories and files
    	location ~ (?:^|/)\. {
    		deny all;
    	}
    	
    	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:4567/;
    		proxy_redirect off;
    
    		# Socket.IO Support
    		proxy_http_version 1.1;
    		proxy_set_header Upgrade $http_upgrade;
    		proxy_set_header Connection "upgrade";
    	}
    
    	include /usr/local/nginx/conf/staticfiles.conf;
    	include /usr/local/nginx/conf/php.conf;
    	include /usr/local/nginx/conf/drop.conf;
    	#include /usr/local/nginx/conf/errorpage.conf;
    	include /usr/local/nginx/conf/vts_server.conf;
    }
    

    I use centmin mod LEMP web stack.



  • @Cyb3r To go through the paces, comment the include statements that are not already commented. Comment the location ~ block. What you should be left with is the bare minimum configuration and one location block, that being location /.

    RESTART Nginx. Give that a try.



  • @rod said in Site is not working properly with nginx proxy?:

    @Cyb3r To go through the paces, comment the include statements that are not already commented. Comment the location ~ block. What you should be left with is the bare minimum configuration and one location block, that being location /.

    RESTART Nginx. Give that a try.

    Thanks that's seemed to work only one file is missing now: plugins/nodebb-plugin-markdown/styles/railscasts.css

    Edit: Now it's working great!

    Thanks guys I really appreciate the help and I love NodeBB. Easy, fast and elegant software.

    Cheers!


  • Admin

    Thanks @rod and @tqwhite for helping @Cyb3r with this 😄

    Glad we have you on the community!


Log in to reply
 


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