我有配置文件:
server {
listen 80;
root /path/to/file/;
location /api/ {
proxy_pass http://0.0.0.0:5000/api/;
}
location /docs/ {
index /path/to/another/index/filename.html;
}
}
但是当我试图在浏览器中调用/ docs /时,我在error.log中看到服务器试图在root / path / to / file /中找到docs文件而不是从第二个位置块返回另一个html文件。
如何将请求/ docs /代理到位于文件系统上的另一个docs.html?
index
只描述默认情况下要提供的文件。你需要的关键字是root
:
location /docs {
root /path/to/another/index;
index filename.html;
}
现在,当访问route / docs /时,Web服务器将提供/path/to/another/index/filename.html
。