【发布时间】:2018-05-10 18:22:25
【问题描述】:
我在 AWS ec2 实例上托管了我的 Angular 项目。 实例已成功创建,站点正常运行。
什么时候提出请求 www.abc.com 它可以工作,但是当我请求 www.abc.com/login 它返回 nginx 错误
404 未找到
app.routing.ts
const routes: Routes = [
{
path: '',
loadChildren: './layout/layout.module#LayoutModule',
canActivate: [AuthGuard]
},
{ path: 'signup', loadChildren: './signup/signup.module#SignupModule' },
{ path: 'login', loadChildren: './login/login.module#LoginModule' },
{ path: 'not-found', loadChildren: './not-found/not-found.module#NotFoundModule' },
{ path: '**', redirectTo: 'not-found' },
];
服务器配置 nginx(启用站点)
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/myfolder;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
这是角码问题还是服务器配置问题? 如何解决?
【问题讨论】:
-
我认为服务器名称可能是 nginx 中的问题。请尝试使用域名而不是 _ server_name www.abc.com
-
还是同样的问题...