nginx - Nginx 路由配置
问题描述
最近在学习nginx。下面的路由配置看不懂。谁能解释一下?谢谢!
root /home/ubuntu/demo/web_file;
location / {
root /home/ubuntu/demo/web_file/production;
index index.html index.htm;
}
location /vendors {
index index.html index.htm;
}
location /src {
index index.html index.htm;
}
location /build {
index index.html index.htm;
}
解决方案
指令的值root
是从周围的块继承的,如果它本身没有指定的话location
。有关详细信息,请参阅此文档。
该块实际上是默认位置,并匹配任何与其他块location /
不匹配的 URI 。location
在您的配置中,您为所有 URI 指定根,但以、或/home/ubuntu/demo/web_file/production
开头的那些除外。/vendors
/src
build
您不需要index
在每个位置重复相同的语句,因为它也是从周围的块继承的,如果它location
本身没有指定的话。有关详细信息,请参阅此文档。
例如:
root /home/ubuntu/demo/web_file;
index index.html index.htm;
location / {
root /home/ubuntu/demo/web_file/production;
}
location /vendors {
}
location /src {
}
location /build {
}
推荐阅读
- c# - 向目标对象平滑旋转对象
- android - 有没有办法在 Kotlin 中使用 coroutines/Flow/Channels 实现这个 rx 流?
- cypress - 赛普拉斯测试运行程序不呈现 Blockly 类别
- python - 如何将文件从云存储复制到其他云?例如,Google Drive 到 OneDrive
- java - 我想知道如何将一组字符串类型的数组列表添加到数组列表中
- php - 查看类别的帖子
- google-maps - 如何从 markerCluster 中删除一个标记
- java - 如何告诉自定义适配器使用我的类列表而不是填充\添加项目?
- php - 如何在 ampify_img 函数中获取图像的 src
- amazon-ec2 - 停用 AWS EKS 主服务器?