Custom domain gives error 400 with Azure CDN - azure

I'm trying to access my content on my Azure CDN via a a custom domain (cdn.mydomain.com/pictures/logo.jpg)
But I get an error 400:
<Error>
<Code>InvalidUri</Code>
<Message>
The requested URI does not represent any resource on the server. RequestId:8fa9ea29-e46f-4053-a902-5707d19e1520 Time:2011-05-13T09:40:08.3459953Z
</Message>
<UriPath>http://cdn.mydomain.com/pictures/logo.jpg</UriPath>
</Error>
However, when accessing through the URL given på Azure (accountname.blob.core.windows.net) things work perfectly.
The storage is created a few weeks ago, and so is the custom domain. I've created a CNAME and pointed it to accountname.blob.core.windows.net.
How to show content from my custom domain?
EDIT: I tried pointing my custom domain to xxxxxxx.vo.msecnd.net. Now, all I get is a blank page. I can't seem to figure out where to point my custom domain. No matter what, I end up with a http error 400.

I have not used the Azure CDN, but I suggest you verify that your CNAME is set up properly. Try dig your DNS name and check that it includes something like
;; ANSWER SECTION:
cdn.mydomain.com. 7200 IN CNAME accountname.blob.core.windows.net.

Have you followed the CName mapping instructions in http://blog.smarx.com/posts/using-the-new-windows-azure-cdn-with-a-custom-domain ?

Related

How to block crawling of the origin when Azure CDN is configured

something is not clear using Azure CDN.
I explain step by step what I have done since my website has been created. Call my website www.mypublicwebsite.com. So:
I created a web app on Azure. The website has the following url: https://mypublicwebsite.azurewebsites.net;
I created a custom domain www.mypublicwebsite.com
I redirected all the request from https://mypublicwebsite.azurewebsites.net to www.mypublicwebsite.com. So I solved the problem of duplicated contents for crawlers.
Everything is fine. Then, I decided to create CDN, according the documentation. Here the confusion starts.
I created the CDN profile
I created the endpoint. The endpoint has a new url https://mypublicwebsite.azureedge.net
I deleted the custom domain from web app;
I created the custom domain in cdn profile.
So the current state is this:
This situation is really problematic for SEO!! It cannot be the correct configuration. My contents are triplicated.
I partially solved the situation:
I redirected all the request from https://mypublicwebsite.azureedge.net to www.mypublicwebsite.com. So I solved the problem of duplicated content for crawlers.
But crawler (and perhaps users?) can still navigate the origin web site. I have been looking for different solutions:
Make a redirect from https://mypublicwebsite.azurewebsites.net to www.mypublicwebsite.com. But this create a infinite redirects loop between the CDN and the origin.
Try to hide the origin, but how?
I am honestly starting thinking this is not the correct way to manage cdn.
Can anyone help me please?
Thank you

SenderGrid sender authentication

I have a Next.js (deployed with Vercel) app and I am trying to implement SendGrid to create a contact form on my site.
I have followed this tutorial
when trying to submit the form I get the following error:
POST http://localhost:3000/api/send 400 (Bad Request)
I believe the issue is around sender authentication. (https://app.sendgrid.com/settings/sender_auth)
My domain provider is '123-reg'.
I have added the dns records from Sendergrid to the 123 dns section. However when I click on verify I get the following errors:
I can't seem to verify these records.
UPDATE
I have actually updated my Vercel dashboard domains section with the values provided from SendGrid but I still get the same errors:
It seems you are using Vercel (Zeit Now) for your DNS and you haven't configured the SendGrid DNS records that the service requires.
When adding CNAME to the Vercel DNS interface, try adding only the subdomain part. This means em8573 instead of em8573.alex-web.co.uk and so on.
You can find instructions on how to create CNAME here.
You can easily test your records using Dig web interface, an amazing web service.
if your domain doesn't match 'alex-web.co.uk' then it will not work. Ensure the CNAME has the correct domain. If it matches your domain name Vercel will auto remove the domain name from your CNAME.

Unreachable gitlab page with custom domain

I created a site with Hugo and I hosted it as a gitlab page.
To assign my custom domain I followed the instructions of this document of gitlab.
I created three DNS records:
one of type A with name # and value 35.185.44.232;
one of type TXT with name # and value _gitlab-pages-verification ... for the verification of the ownership of the domain;
one of type A with name www and value 35.185.44.232.
If I access the site using the address https://example.com everything works normally; but if I log in using the triple W (www.example.com) I get from gitlab the error message 401 You don't have permission to access the resource. The resource that you are attempting to access is protected and you don't have the necessary permissions to view it.
How can I correct it?
Try a CNAME instead of a second A record for your WWW. subdomain. Having two A records - one that points to your naked domain and one that points to your WWW-domain is either causing redirect error or simply does not exist since it, as your origin's subdomain, must exist as a separate entity on GitLab OR you can not concern yourself with it by using a CNAME record as I previously recommended and using a directory-style (as opposed to a subdomain-style) setup for your site. Each has its own benefits as well as drawbacks. I use the CNAME method and have a WWW-subdomain setup on GitLab in order for my sites to grant that extra bit of security and privacy to visitors that having a TLS cert installed on the WWW-subdomain offers.

Override redirect URL in AddMicrosoftAccount() identity OAuth for ASP.NET Core web app

I have a website deployed to Azure. I've used Cloudflare in order to CNAME the azurewebsites domain, and therefore set the redirect URL to the Cloudflare hosted domain name as:
https://www.example.com/signin-microsoft
When I try and login, I get a failure, and the link provided by Microsoft is:
https://login.live.com/err.srf?lc=1033#error=invalid_request&error_description=The+provided+value+for+the+input+parameter+'redirect_uri'+is+not+valid.+The+expected+value+is+'https://login.live.com/oauth20_desktop.srf'+or+a+URL+which+matches+the+redirect+URI+registered+for+this+client+application.&state=xxx
When I run Fiddler, I can see that the redirect URL passed through by my app, is not the https://www.example.com, but the following:
/common/oauth2/v2.0/authorize?client_id=f0caa31c-3117-4479-a284-65f5a38ff5b6&scope=https%3A%2F%2Fgraph.microsoft.com%2Fuser.read&response_type=code&redirect_uri=https%3A%2F%2Fexample.azurewebsites.net%2Fsignin-microsoft
When I setup the Microsoft OAuth in my app, I have these settings, but I can't find one to override the redirect-url:
services.AddAuthentication().AddMicrosoftAccount(microsoftOptions =>
{
microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ApplicationId"];
microsoftOptions.ClientSecret = Configuration["Authentication:Microsoft:Password"];
});
Does anyone have any suggestions? To complicate the matters, I've got this structure:
Cloudflare
Azure CDN
Azure Web app
You can double check the redirect URL is expecting by checking the application AAD reply URLs with the instructions here. This must be an exact match to what you are sending in your request. If can take a few minutes for updates to propagate, so give it some time after you update this setting for errors to resolve.
I was able to override the redirect uri using a similar strategy to the answer in this question.
.AddMicrosoftAccount(microsoftOptions =>
{
microsoftOptions.ClientId = Configuration["AzureAd:AppId"];
microsoftOptions.ClientSecret = Configuration["AzureAd:Password"];
microsoftOptions.AuthorizationEndpoint = Configuration["AzureAd:AuthEndpoint"];
microsoftOptions.CallbackPath = "/signin-oidc";
microsoftOptions.Events.OnRedirectToAuthorizationEndpoint = context =>
{
context.Response.Redirect(Regex.Replace(context.RedirectUri, "redirect_uri=(.)+%2Fsignin-oidc", "redirect_uri=https%3A%2F%2Fwww.yourcustomdomain.com%2Fsignin-oidc"));
return Task.FromResult(0);
};
});
The problem is due to a conflict between CloudFlare's CNAME flattening and Azure's CNAME verification. The CNAME flattening essentially returns A records, which speeds up DNS resolution and is a good idea in general. However, Azure's CNAME verification only verifies CNAME records.
The best workaround I've found is to:
1.Disable CloudFlare's HTTP proxying (click the orange cloud on that CNAME record so that it turns grey); this also disables CNAME flattening for that record.
2.Check your host on dig until you see the CNAME records show up.
3.Verify your CNAME host on the Azure portal.
4.Re-enable CloudFlare's HTTP proxying (click the grey cloud on that CNAME record so it turns orange).
This allows you to verify on Azure and still take advantage of CloudFlare's CDN.
For more details, you could refer to this article.

Azure A Records gives 404

I have a website hosted at Azure, registered {0}.com and www.{0}.com as custom domain, both are working fine!
But if I use the plain IP which I put into the A record, it gives me an 404.
My understanding is that the plain IP address should also return the website, am I wrong? If it should do so, whats my mistake?
Did you create an “awverify” record in your domain register? You need to create a special CNAME record that is used to verify you own your domain. This is required if you are going to use A record, and is not necessary for CNAME. You can check http://azure.microsoft.com/en-us/documentation/articles/web-sites-custom-domain-name/.

Resources