首页 > 解决方案 > 502 - Web server received an invalid response while acting as a gateway or proxy server on Azure App Server

问题描述

502 - Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

I am working Headless Browser that is ChromiumWebBrowser thats work fine on local machine and when we publish code on Azure App Service this gives us above mentioned error. Currently we use Shared infastructured (Free version for Testing).

region ChromiumWebBrowser

        var browser = new ChromiumWebBrowser(url);

        await LoadPageAsync(browser);

        var result = browser.GetBrowser().MainFrame.GetSourceAsync().Result;

        browser.Stop();
        if (!browser.IsDisposed)
            browser.Dispose();

        #endregion

标签: web-scrapingazure-web-app-servicechromium

解决方案


感谢提问!只是为了确认您是否使用 GDI?由于使用无头浏览器 ChromiumWebBrowser 主要需要 GDI 支持和 Windows 上的 Azure App Services,因此与Win32k.sys (User32/GDI32) Restrictions冲突,如前所述,

为了彻底减少攻击面,沙箱阻止了几乎所有的 Win32k.sys API 被调用,这实际上意味着大部分 User32/GDI32 系统调用都被阻止了。对于大多数应用程序来说,这不是问题,因为大多数 Azure Web 应用程序不需要访问 Windows UI 功能(它们毕竟是 Web 应用程序)。然而,受影响的一种常见模式是 PDF 文件生成。有几种情况需要注意:

建议您查看有关Chrome driver is not working on azure web apps 的讨论


推荐阅读