i'm having a little issue with Rasmus Andersson awesome node.js EC2 template http://rsms.me/2011/03/23/ec2-wep-app-template.html
ok, the issue is
i would like the root url http://www.mydomain.com/ response to be delivered by the node.js server (which listens on port 3000)
nginx should still deliver everything static from /public/ (so nginx should look in /public/ first, if it's not there pass the request to node.js on port 3000) i.e.:
- http://www.mydomain.com/favicon.ico should response with the file from /var/mydomain/public/favicon.ico
- http://www.mydomain.com/ should be passed to node.js on port 3000
- http://www.mydomain.com/contentpage.html should be passed on to node.js on port 3000
this is my /etc/nginx/sites-available/mydomain-http
config file. i know that i will have to rewrite the location / part, but i don't know what i should put in there.
thx a lot
## Access over HTTP (but not HTTPS)
server {
listen 80;
listen [::]:80 default ipv6only=on;
access_log /var/log/nginx/access.log;
location / {
root /var/m开发者_如何学运维ydomain/public;
index index.html;
error_page 404 = @backend;
}
location @backend {
proxy_pass http://127.0.0.1:3000;
proxy_set_header X-Client-IP $remote_addr;
}
}
i'm answering this question myself as i found the solution after a lot of "oh my ...... ... i can't believe this does not work". what was missing in my case, was
error_page 403 = @backend;
in the main server block, as a request for / did not return an http 404 (file not found), but an http 403 (no access).
the issue was submitted back to the project as issue nr. 5 https://github.com/rsms/ec2-webapp/issues#issue/5
精彩评论