IIS Reverse Proxy How to fix the location header

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Rachel S
    Senior Member
    • Apr 2022
    • 164

    IIS Reverse Proxy How to fix the location header

    VPS Hosting
    Hi,

    We have an IIS server running as a reverse proxy for terminology.hl7.org. Requests coming in with a host of terminology.hl7.org are redirected to an internal server at http://3.142.231.50/terminology.


    If the request is for http://terminology.hl7.org/6.2.0, the server at 3.142.231.50 issues a redirect with a Location header of http://3.142.231.50/terminology/6.2.0/. IIS reprocesses this header to http://terminology.hl7.org/terminology/6.2.0/.

    ​Any suggestions to tackle this?
  • Ryaan J.
    Senior Member
    • Apr 2022
    • 164

    #2
    You must strip the /terminology path from the rewritten Location header in IIS.

    Use ARR and URL Rewrite with outbound rule.

    1. Ensure Application Request Routing (ARR) is installed
    • Open IIS Manager → Server node → "Application Request Routing Cache"
    • Click "Server Proxy Settings"
    • Check "Enable proxy"
    2. Add an Outbound Rewrite Rule for the Location header

    Go to the site (or server level if global):
    • Open "URL Rewrite"
    • Click "Outbound Rules"
    • Add New Outbound Rule → Blank Rule

    Implement this setting:
    • Name: FixLocationHeader
    • Precondition: Create new
    Precondition:
    • Name: IsResponseRedirect
    • Condition input: {RESPONSE_STATUS}
    • Check if input string: Matches the Pattern
    • Pattern: 3\d{2}
      (Matches 301/302/307/308)
    Outbound Rule Configuration:
    • Matching scope: Response Headers
    • Variable name: Location
    Matching pattern:

    http://3\.142\.231\.50/terminology/(.*)

    Action type: Rewrite

    Value: http://terminology.hl7.org/{R:1}

    3. Apply and Restart IIS with iisreset

    Test using : http://terminology.hl7.org/6.2.0

    Backend redirects to: http://3.142.231.50/terminology/6.2.0/

    Comment

    Working...
    X