【发布时间】:2021-01-27 01:05:41
【问题描述】:
我对如何使用 nginx 为我的 angular 应用程序提供服务有点迷茫。要求是访问应用程序的url必须属于:www.domain-name.com/rte
我在路径上的 docker 上有应用程序文件:/usr/share/nginx/html/
我的 default.conf 看起来像:
location /rte {
alias /usr/share/nginx/html/;
try_files $uri$args $uri$args $uri $uri/ /index.html;
}
但是当我尝试访问该页面时,会发生超时。
我已经尝试过这个aswel:
location /rte/
然后抛出 404。
编辑:我的 index.html 有 -> base href="/"
【问题讨论】:
-
听起来您需要在部署之前将
base href更改为/rte/,或者使用--base-href选项编译将base href设置为/rte/的应用程序。看到这个:angular.io/cli/build -
@R.Richards 我应该使用
/rte/还是/rte? -
我会先尝试
/rte/。过去,它对我来说完全没有斜线。你可能不得不玩弄它。 -
我试过了,效果很好!谢谢!