我想将我的nginx配置为满足以下请求:
http://example.com/vk-lang-training/
返回/var/www/vk-lang-training/build/index.html
我的配置代码段是
location /vk-lang-training/ {
root /var/www/vk-lang-training/build;
index index.html;
}
但是我收到404错误,并在error.log中看到
2019/12/11 09:56:19 [error] 8434#8434: *2 "/var/www/vk-lang-training/build/vk-lang-training/index.html" is not found (2: No such file or directory)
正如我所见,它调用/var/www/vk-lang-training/build/vk-lang-training/index.html
而不是/var/www/vk-lang-training/build/index.html
如何返回/var/www/vk-lang-training/build/index.html
?
答案 0 :(得分:0)
似乎我找到了解决方法。
我必须使用root
而不是alias
。像这样
location /vk-lang-training/ {
alias /var/www/vk-lang-training/build/;
index index.html;
}