【发布时间】:2018-02-03 08:08:39
【问题描述】:
我有一个网站,它是一个包含其他应用程序的应用程序。 在主应用中,我将使用 iframe 加载其他应用。
主应用程序在域根目录中提供服务:http://example.com 其他应用程序在 /apps 路径下提供:
此外,这些应用程序是在 Polymer 中开发的,因此有客户端导航。我确保客户端没有使用 /apps 路径来正确访问 NGINX 服务器,但这也意味着对于诸如 http://example.com/view1 之类的 url,它应该重定向到主应用程序的 index.html。对于像http://example.com/apps/app-b/view1 这样的url,它应该重定向到app-b 的index.html。
我正在尝试配置 NGINX 来为这些静态应用提供服务。
server {
listen 80;
server_name example.com;
root /var/www/example.com/main-app;
index index.html;
try_files $uri $uri/index.html /index.html;
location ~ /apps/([a-z-]+) {
alias /var/www/example.com/apps/$1;
}
}
通过上面的配置,我的主应用程序可以正确重定向到 index.html 的 /view1 路径。
但我的子应用程序出现 403 禁止错误。
“/var/www/example.com/apps/app-b”的目录索引被禁止, 客户端:127.0.0.1,服务器:example.com,请求:“GET /apps/app-b/
我尝试了其他配置但没有成功(无限重定向导致 /index.html/index.html/index.html...)。
我确定所有目录的文件系统权限都是 755,文件是 644。
我不知道它为什么要创建目录索引。 任何帮助表示赞赏。
【问题讨论】:
标签: nginx nginx-location