我在VPS上运行node.js API,由Ubuntu 13.04上的nginx提供服务。静态文件在本地提供,但不通过nginx
我使用restify和服务静态文件是这样的:
server.get(
/\/static\/?.*/,
restify.serveStatic({
directory: __dirname // => /home/misha/rxviz-api
})
);
下面是相关位nginx的配置:
server {
listen 80;
server_name api.rxviz.com;
location/{
proxy_pass http://localhost:4010/;
}
}
(满配置为here)
当运行:
curl http://localhost:4010/static/.well-known/acme-challenge/test.json
关于VPS,我得到test.json
的内容。
但是,导航时:在浏览器中
http://api.rxviz.com/static/.well-known/acme-challenge/test.json
,我得到404
nginx的错误日志显示/opt/nginx/html/static/.well-known/acme-challenge/test.json
没有找到。
为什么nginx试图访问/opt/nginx/html
中的test.json
而不是/home/misha/rxviz-api
?
数点:
static
目录的权限是drwxrwxr-x
- 我可以在浏览器中访问
http://api.rxviz.com/
成功
IFAIK,“root”正在追加,但“别名”不是。 (无论如何,我尝试过'alias/home/misha/rxviz-api /;',但仍然是404)。 –
我也尝试从nginx配置中删除'location/static/{...}',但仍然是404。 –
是否在编辑或删除后重新启动了nginx守护进程?因为很奇怪你删除了位置块,你仍然可以尝试使用404 –