Skip to content

400 error when hosted on Azure? #30

Open

Description

@conficient

We have a legacy WebForms app and Blazor Server front-end using Cocoon successfully for a year. It's hosted on our own servers at present and its working perfectly.

Problem

I'm trying to port the same code to be hosted on Azure. I've set up two App Services running in the same service plan (both as Windows hosts). One is running the WebForm app (on .NET Framework 4.8) and the other running Blazor (on .NET 6).

Both apps are up and running independently, but if I try to access a Cocoon page from the Blazor app, it returns a 400 error.

This is the case even if I try to request a static resource, e.g. /img/Test.jpg. This exists on the WebForm app, but it fails and returns a 400 error. From the Blazor site log (below) I can see that it Initially tries to request the /facadeauth route on the target, even though it's accessing a static file, which returns a 401 error. I can query the URL on the webform site, e.g. https://webform-site-url/img/Test.jpg and it works.

2023-03-09 16:45:27.314 +00:00 [INF] Executing endpoint '/{**catch-all}'
2023-03-09 16:45:27.314 +00:00 [INF] Proxying to https://webform-site-url/img/Test.jpg HTTP/2 RequestVersionOrLower no-streaming
2023-03-09 16:45:27.328 +00:00 [INF] Request starting HTTP/1.1 GET https://blazor-site-url/img/Test.jpg - -
2023-03-09 16:45:27.329 +00:00 [INF] Start processing HTTP request GET "https://webform-site-url/facadeauth"
2023-03-09 16:45:27.330 +00:00 [INF] Sending HTTP request GET "https://webform-site-url/facadeauth"
2023-03-09 16:45:27.334 +00:00 [INF] Received HTTP response headers after 3.1655ms - 401
2023-03-09 16:45:27.335 +00:00 [INF] End processing HTTP request after 5.6275ms - 401
2023-03-09 16:45:27.336 +00:00 [INF] Executing endpoint '/{**catch-all}'
2023-03-09 16:45:27.336 +00:00 [INF] Proxying to https://webform-site-url/img/DefaultLogo.jpg HTTP/2 RequestVersionOrLower no-streaming
2023-03-09 16:45:27.345 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.346 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.347 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 18.8249ms
2023-03-09 16:45:27.348 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.349 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.350 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 43.3374ms
2023-03-09 16:45:27.351 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.351 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.352 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 74.3990ms
2023-03-09 16:45:27.354 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.364 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.365 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 112.8046ms
2023-03-09 16:45:27.366 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.366 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.372 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 152.5473ms
2023-03-09 16:45:27.374 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.375 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.380 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 189.8787ms
2023-03-09 16:45:27.381 +00:00 [INF] Received HTTP/1.1 response 400.

Any ideas??

Activity

  1. conficient commented on Mar 10, 2023

    @conficient
    ContributorAuthor

    I did consider whether HTTP/2 might be an issue so I limited the WebForms app to HTTP/1.1, this didn't change anything

  2. conficient commented on Mar 10, 2023

    @conficient
    ContributorAuthor

    I suspect this is something Azure related: I tried moving the Blazor project to a Linux host which is on a different IP. It was unable to talk to the WebForm app. I will search in the YARP issues to see if there are any known problems...

  3. conficient commented on Mar 24, 2023

    @conficient
    ContributorAuthor

    Posted an issue on the Reverse-Proxy repository and fortunately someone hit on the right solution.

    When forwarding the request to the destination, the headers (including the Host value) are copied. Since the Azure App Service hosts many sites on the same IP it uses DNS and the Host header (I believe) to resolve which App Service to route the traffic to.

    Since the Host value and the URL were in conflict I believe the router refused the request - hence the 400 error.

    I've added a fix to the RedirectTransformer and will send a pull request for it

  4. added a commit that references this issue on Apr 13, 2023
    56b3613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions