express - How to get req.hostname when running node.js behind apache with mod_proxy -
my node.js application uses req.hostname
in order redirect pages http https this:
app.get('*', function(req, res){ res.redirect('https://' + req.hostname + req.url); });
this works when running application on localhost. when application runs on server behind mod_proxy req.hostname
not contain domain name. instead contains localhost
. how domain name?
on apache settings have add this:
proxypreservehost on
this tell apache preserve hostname when doing proxy pass node application
Comments
Post a Comment