I have a particular URI scheme that is causing me some trouble. I need to run nodejs to serve the following:
domain.com
var.domain.com
var.domain.com/foo/
I have this working no problem using express.vhost()
to serve up the sub domains.
However, I need serve static content and php once the URI resembles the following:
var.domain.com/foo/bar
var.domain.com/foo/bar/index.php
Here, /bar/
is some directory on my server. Everything from that url down (say /bar/images/favicon.ico
) would serve like your typical directory scheme. Normally I would do the typical proxy_pass to node running on some port, but as you can see here, I need nodejs to be the primary handler on port 80, and have it pass the request off to nginx running on some other port (Or would it be possible/simpler the other way around?).
Is this type of scheme possible with a (nginx/php) / nodejs configuration?
Nginx allows very flexible request routing. I will show you a way to set up
I like, and I think that's the default setup layout for most distros, to have
conf.d
andvhosts.d
directories withactive
andavailable
folders. So I can easily disable a vhost or configuration file by simply deleting the symlink./etc/nginx.conf
/etc/nginx/vhosts.d/available/default.conf
Say our document root for static files is
/srv/www/vhosts/static/htdocs
create a symlink to make the default vhost active
See how simple and intuitive the nginx configuration language is? I just HAVE to love it :)