I am wants using Nginx as reverse proxy for my express.js app.
here is my nginx config :
server {
listen 80;
server_name my server ip address;
location / {
proxy_pass http://myip:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
and its my app.js :
var express = require('express');
var mongoose = require('mongoose');
var app = express();
app.set('view engine' , 'ejs');
app.use(express.static('public'));
app.get('/song', function(req, res, next) {
// my route
}
without nginx my app works very well but when i using nginx as reverse proxy and go to my song
route node give me this error : Failed to lookup view "default" in views directory
i want know where i am wrong. thanks.
I faced the same problem after configuring Nginx server. I found the solution.
The node couldn't able to find the path for the "views" folder in the project. so define the path.
var path = require("path");
app.set('view engine' , 'ejs');
app.set("views", path.join(__dirname, "views"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With