我对Rasmus Andersson很棒的node.js EC2模板http://rsms.me/2011/03/23/ec2-wep-app-template.html
有一点问题好的,问题是
我希望node.js服务器(侦听端口3000)传递根URL http://www.mydomain.com/响应
nginx应该仍然从/ public /提供静态的所有东西(所以nginx应该在/ public / first中查找,如果它没有将请求传递给端口3000上的node.js) 即:
这是我的/etc/nginx/sites-available/mydomain-http
配置文件。我知道我将不得不重写位置/部分,但我不知道我应该把它放在那里。
## Access over HTTP (but not HTTPS)
server {
listen 80;
listen [::]:80 default ipv6only=on;
access_log /var/log/nginx/access.log;
location / {
root /var/mydomain/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;
}
}
答案 0 :(得分:3)
我自己回答了这个问题,因为我在很多“哦,我的......我不敢相信这不起作用”之后找到了解决方案。在我的案例中缺少的是
error_page 403 = @backend;
在主服务器块中,作为请求/没有返回http 404(文件未找到),而是一个http 403(无访问权限)。
该问题已作为问题提交回项目。 5 https://github.com/rsms/ec2-webapp/issues#issue/5