I'm serving multiple angular apps from the same server block in Nginx.
(我正在Nginx的同一服务器块中提供多个角度应用程序。)
I'm forwarding these routes from nginx to each angular app's index.html, I've added a try_files to each location: (我将这些路由从nginx转发到每个角度应用程序的index.html,并在每个位置添加了try_files:)
listen 80;
server_name website.com;
# project1
location / {
root /home/www/html/project1/dist/;
try_files $uri $uri/ /index.html;
}
# project2
location /project2/ {
root /home/www/html/project2/dist/;
try_files $uri $uri/ /index.html;
}
}
This solution avoids the 404 error when going to an Angular route, but the problem is that how could I route to assetes of each project
(此解决方案避免了在执行Angular路线时出现404错误的问题,但是问题是我该如何路由到每个项目的资产)
location /assets{
??
}
Is there any config in nginx so without making changes in angular code , or change places of each project assets ?
(nginx中是否有任何配置,因此无需更改角度代码或更改每个项目资产的位置?)
ask by asmaa mahmoud translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…