I have a domain name like sub.example.com
and I can serve apps using it by adding another subdomain level, like test.sub.example.com
. It works fine and I could serve multiple apps one on app1.sub.example.com
and another on app2.sub.example.com
.
Now I have an angular app that I've served using nginx on app.sub.example.com
using the following configuration:
server {
server_name app.sub.example.com;
listen 80;
root /var/www/app;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
It works fine and all, but the only problem I found is that if I hit a subdomain that isn't configured yet, like say app-test.sub.example.com
I get redirected to my /not-found
endpoint on the angular application i.e., app-test.sub.example.com/not-found
and I can see the not found page.
// not found route configuration in the routes array
{ path: 'not-found', component: PageNotFoundComponent, title: 'Page Not Found' },
{ path: '**', redirectTo: 'not-found', pathMatch: 'full' }
Am I missing something on the nginx configuration for the Angular application? Or is it something related to the routing on Angular? \
Edit:
Actually all requests seems to be redirected to the Angular application, I tried hitting app-test.sub.example.com/
and it got me to the index page on the Angular application.