我在 nginx 上部署了一个 Web 应用程序,其服务器名称为 example.com
,位于路径 var/www/app
下。
我添加了另一个目录 var/www/demo
,它只包含一个静态的 .html
页面;有没有可能像 example.com/demo
一样?
我已经在 /etc/nginx/sites-enabled
中创建了一个包含以下内容的文件:
server {
location /demo {
root /var/www;
}
}
但它不起作用,有人可以帮忙吗?
答案 0 :(得分:0)
阅读http://nginx.org/en/docs/http/ngx_http_core_module.html#root
server {
root /var/www/;
location /app {
index index.html;
}
location /demo {
index index.html;
}
}
文件夹结构是
/var/www/app/
--- /var/www/app/index.html
/var/www/demo/
--- /var/www/demo/index.html
$# curl localhost/demo/
<html>
it works
</html>