CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • 502 - Web server received an invalid response while acting as a gateway or proxy server

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    4239
  • Date Created
    Wednesday, March 30, 2022
  • Last Updated
    Monday, February 5, 2024
  • This Article Has been Viewed
    423 times
  • Short Desc
    IIS ARR Web Server gives 502 bad gateway error.
  • Details
    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.
  • Recreate Issue
    Scenario #1:
    [SSL Certificates are not the same throughout the IIS Server Farm].

    When building an [ARR Server Farm], all machines must match; if not, you will
    receive the [502 Bad Gateway error]. The [SSL Certificate] is just one of many
    different issues if the configurations are not identical.
  • Resolve Issue
    Scenario #1:
    Ensure all [SSL Certificates] are the same on all machines throughout the [IIS Server Farm].
    These include the [ARR] (Application Request Routing) and [IIS Servers].

    To ensure they are the same, it is best to Export the most recent [SSL Web Server
    Certificate
    ] from the known good server and copy and install this certificate
    throughout the [IIS Server farm].

    All codes are done in Powershell.
    If running from a Command Prompt (CMD)
    Simply type in: Powershell
    Hit enter, and then copy the below codes.
    Export
    :: First, we need to find out if the SSL key exists
    dir cert:\localmachine\webhosting | Where-Object { $_.hasPrivateKey }

    :: If it does, then we launch this script
    $mypwd = ConvertTo-SecureString -String "PASSWORD-GOES-HERE" -Force -AsPlainText
    Get-ChildItem -Path cert:\LocalMachine\webhosting | Export-PfxCertificate -FilePath G:\SSL\Most-Recent-SSL-Cert.pfx -Password $mypwd



    :: Copy from the known good IIS Cert to the server to install on.

    Copy-Item -Path '\\WebServer-Name\G\SSL\certs\Most-Recent-SSL-Cert.pfx' -Destination \\Webc01\g\SSL\Most-Recent-SSL-Cert.pfx


    :: Import to the Server
    $pwd = ConvertTo-SecureString -String "PASSWORD-GOES-HERE" -Force -AsPlainText
    Import-PfxCertificate -FilePath G:\SSL\Most-Recent-SSL-Cert.pfx Cert:\LocalMachine\WebHosting -Password $pwd