some code example to illustrate

We recently had a client that needed to expose a legacy system that only responded to the production host (ex. used by the website on DXP.

To achieve this we needed to implement a reverse proxy using Application Request Routing and URL Rewrite that would allow the legacy path ( to be displayed on the site.

Activate the proxy functionality in the Azure website

Add the file applicationHost.xdt to your repo. It does not need to be included in your Visual studio project.

<?xml version="1.0"?>
<configuration xmlns:xdt="">
    <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="true" reverseRewriteHostInResponseHeaders="false" />
<location path="%XDT_SITENAME%" xdt:Locator="Match(path)">
    <system.webServer xdt:Transform="InsertIfMissing">
        <rewrite xdt:Transform="InsertIfMissing">
            <allowedServerVariables xdt:Transform="InsertIfMissing" >
                <add name="HTTP_X_USE_HTTPS"                xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_X_ORIGINAL_HOST"            xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_X_UNPROXIED_URL"            xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_ACCEPT_ENCODING"            xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_HOST"                       xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
                <add name="HTTP_URL"                       	xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />

Add your rewrite rules for the system to be proxied to web.config

In our case the legacy system only responded to our production URL so we needed to manipulate the host in the request to the legacy system. The system itself had a separate host that was mapped to the actual server but the application on said server was not bound to the server host.

            <rule name="ProxyFureg" stopProcessing="true">
                <match url="^legacysystempath/(.*)" />
                <action type="Rewrite" url="http://legacyserver:8081/legacysystempath/{R:1}" />
                    <set name="HTTP_URL" value="{R:1}" replace="true"/> 
                    <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" /> 
                    <set name="HTTP_X_ORIGINAL_HOST" value="" />
                    <set name="HTTP_HOST" value=""  replace="true"/>
                    <set name="HTTP_ACCEPT_ENCODING" value="" />

Note that we added additional rewrite rules to handle any additional resources of the legacy system required such as stylesheet and script paths.

Make sure that the applicationHost.xdt is added to the nuget package when Deploying

In Azure website the applicationHost.xdt file needs to be outside of the wwwroot folder (in our case /site).
Our build process is based on Azure DevOps pipelines and the Epinova DXP Deployment extension (Here is the start of our Blog posts detailing more about our deployment process).
To achieve the final step we needed to add the following task to our pipeline YAML file (azure-pipeline.yml that is included in the root of our repo).

- task: [email protected]
  displayName: 'Build solution $(solution)'
    solution: '$(solution)'
    msbuildArgs: '/p:Configuration=Release;MvcBuildViews=true;DeployOnBuild=True;DeployDefaultTarget=WebPublish;WebPublishMethod=FileSystem;PublishProvider=FileSystem;LastUsedBuildConfiguration=Release;ExcludeApp_Data=False;publishUrl=$(Agent.TempDirectory)/SitePackageContent/wwwroot;DeleteExistingFiles=False'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: [email protected]
  displayName: 'Copy applicationHost.xdt to Site folder'
    SourceFolder: $(Build.SourcesDirectory)
    Contents: applicationHost.xdt
    TargetFolder: $(Agent.TempDirectory)/SitePackageContent
    OverWrite: true
  continueOnError: true

Note that the MSBuild step outputs to /SitePackageContent/wwwroot while we copy the file to /SitePackageContent


The path and it's dependencies such as JS & CSS now show the legacy system thanks to the reverse proxy rules even though it's only accessibly through a hostname that the legacy system knows nothing about.