Friday 14 July 2017

How to serve static js/css files for Node.js using Nginx??

The static files are located in /home/user/xxx_static/public/ directory on the nginx server. Both nginx and nodejs are running on different systems. Here is the conf. for nginx-upstream project { ip_hash; server xxx.xxx.xxx.xxx:PORT; keepalive 64; } server { listen 80; server_name website.com root /home/user/appname_static/public location / { proxy_pass http://project; } } I am including the js files in the handlebars template like -In the app.js file in the Node app -app.use(express.static(path.join(__dirname, 'public'))); When I run my website the developer tools shows the GET Request like this for a file -Request URL:http://ift.tt/2t9Vfvf Status Code:500 Internal Server Error The files are not getting included when i run from nginx server but it works fine when i run the app directly from nodejs server. Please help as i new to nginx and trying to serve the static content of my website via nginx. :)

Submitted July 14, 2017 at 08:24AM by himugamer

No comments:

Post a Comment