6

For my Angular app, here is the app.routing.ts file:

const appRoutes: Routes = [
    { path: '', component: LoginComponent },
    { path: 'dashboard', component: DashboardComponent },
    { path: 'application', component: ApplicationComponent },
    { path: 'decision', component: DecisionComponent },
];

export const routing = RouterModule.forRoot(appRoutes);

so on my local computer, when I do ng serve, then I can go to the address bar in the browser and type in addresses like:

localhost:4200/dashboard

localhost:4200/application

and that works great.

then I do:

ng build --base-href /deploy/ --prod

and then copy the files from the dist folder on my local computer to Azure Blob Storage. I have to have a blob container for the files, and that container is called deploy. I end up with something like:

https://xxyz.blob.core.windows.net/deploy/favicon.ico
https://xxyz.blob.core.windows.net/deploy/index.html
https://xxyz.blob.core.windows.net/deploy/assets/Logo.svg
https://xxyz.blob.core.windows.net/deploy/main.68dbes8ef20.bundle.js
https://xxyz.blob.core.windows.net/deploy/styles.a2b9daa6d36.bundle.css

etc. etc. and I can go to:

https://xxyz.blob.core.windows.net/deploy/favicon.ico

and see the favicon

Then, on the Verizon Edgecast CDN, I can go to:

https://xxyz.com/deploy/index.html to start my app and login.

But I dont want to have to go to https://xxyz.com/deploy/index.html on the CDN to login.

I want to go to

https://xxyz.com/login and login there

Also, I cannot go to these locations on the CDN either:

https://xxyz.com/deploy/dashboard

https://xxyz.com/deploy/application

And what I really want is to be able to do this from the CDN:

https://xxyz.com/login

https://xxyz.com/dashboard

https://xxyz.com/application

and

https://xxyz.com/ should redirect to login page

Im using the Verizon Premium Edgecast CDN, so Im able to do URL Rewrite, but the rules that I have written have not worked so far.

Am I missing anything on the Angular side? Any ideas of URL Rewrite rules for Azure CDN or Edgecast?

Here is the current way I have tried to do URL rewrite for edgecast/Azure: enter image description here

And then here are the options in the drop down that says 'Always' in the image above:

IF options:

Always

As Number

CDN Origin

Client Ip Address

Cookie Parameter

Customer Origin

Edge Cname

Referring Domain

Request Header Literal

Request Header Regex

Request Method

Request Scheme

Url Path Directory

Url Path Extension

Url Path Filename

Url Path Literal

Url Path Regex

Url Path Wildcard

Url Query Literal

Url Query Regex

Url Query Wildcard

user372225
  • 851
  • 2
  • 9
  • 23
  • Could you share the rules you have written with us so that we can better offer help? – Aaron Chen May 31 '17 at 09:26
  • @AaronChen-MSFT I have shared the rules as an image now. thanks! – user372225 May 31 '17 at 19:33
  • I switched to using Azure App Service instead of putting Azure CDN on top of Azure blob storage. In App Service, this kind of rewrite is easy using the web.config file. – user372225 Jul 24 '17 at 14:12
  • Possible duplicate of [Azure CDN rules engine to rewrite default document and remove .html extension](https://stackoverflow.com/questions/37368829/azure-cdn-rules-engine-to-rewrite-default-document-and-remove-html-extension) – Kevin Brey Jul 27 '17 at 06:14

1 Answers1

0

You can set a "Origin path" of 'deploy' in order to remove the '/deploy/' path from being needed in the CDN url.

origin path azure

Rules engine can take up to 90 minutes to start working. Make sure you wait long enough before trying it.

After you add the Origin Path the rewrite rule should just be the following. Rule 1: If always: Feature: URL Rewrite; Source: 'login'; Destination: 'index.html' (from the dropdown, pick the one that matches your endpoint name).

NoCopy
  • 108
  • 4
  • For mapping the root path, you can do this. Feature: URL Rewrite; Source: '/', Destination: 'index.html' – Richard Li - MSFT May 31 '17 at 19:33
  • If you look at the image I attached as part of my question, you can see the 'IF' part, and then a drop down next to it that says 'Always'. I looked in the dropdown where it says 'Always' but I dont see anything that seems to be able to accomplish your suggestion to set 'Origin Path' to 'deploy'. I just added the other options in addition to 'Always' above. Any ideas of which one to use? – user372225 Jun 01 '17 at 14:33