---
title: Running Xperience behind a proxy server
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

If you wish to host Xperience behind a proxy server or another service that takes over the application's public domain (e.g., [Azure Application Gateway](https://azure.microsoft.com/en-in/services/application-gateway/)), you need to ensure request URLs from all parts of the application are generated correctly (targeting the proxy domain). Otherwise, you may encounter issues with [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) policies when performing certain actions (such as uploading images to [Media libraries](https://docs.kentico.com/13/managing-website-content/working-with-files/media-library-files.md)).

![Acesssing an Xperience application through a reverse proxy server](https://docs.kentico.com/docsassets/13/running-xperience-behind-a-proxy-server/Proxy_Server.png "Acesssing an Xperience application through a reverse proxy server")

To correctly configure Xperience running behind a proxy service, you need to:

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

1. [Set up Forwarded Headers Middleware](#setting-up-forwarded-headers-middleware) for your **live site** project.
2. [Configure the site's Presentation URL](#setting-the-sites-presentation-url).
3. [Consider licensing and domain alias requirements](#licensing-and-domain-aliases-in-proxy-scenarios).

## Setting up Forwarded Headers Middleware

See the [Configure ASP.NET Core to work with proxy servers and load balancers](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer) article to learn about Forwarded Headers Middleware.

The following example shows basic forwarded headers configuration in a .NET application's [startup class](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/startup) (_Program.cs_).

```csharp

...

// Configures the Forwarded Headers Middleware options
services.Configure<ForwardedHeadersOptions>(options =>
{
    // Enables processing of all 'X-Forwarded' headers (-For, -Host, -Proto and -Prefix)
    // The 'X-Forwarded-Host' header is required, other headers can be enabled or disabled as required by your proxy environment
    options.ForwardedHeaders = ForwardedHeaders.All;
});

...

// Enables the Forwarded Headers Middleware
app.UseForwardedHeaders();

...

app.UseStaticFiles();
app.UseKentico();

...

```

Adjust the configuration based on the requirements of your proxy environment.

<!-- dev-model:core end -->

<!-- dev-model:mvc start -->

**MVC 5 development model.** Applies only when building with ASP.NET MVC 5. If this page also covers ASP.NET Core, that version is in its own block.

1. [Set the CMSUrlHost configuration key for the live site application](#setting-the-cmsurlhost-configuration-key).
2. [Configure the site's Presentation URL](#setting-the-sites-presentation-url).
3. [Consider licensing and domain alias requirements](#licensing-and-domain-aliases-in-proxy-scenarios).

## Setting the CMSUrlHost configuration key

In the live site application, set the **CMSUrlHost** configuration key to the [host](https://en.wikipedia.org/wiki/URL#Syntax) component of the proxy server's public domain.

1. Edit your live site project's **web.config** file.
2. Add the **CMSUrlHost** key into the  section of the file. Set the key's value to the _host_ component of the proxy server's URL (omitting the port number).

   - For example, assuming the site is running behind the _https://liveDomain.com_ proxy server, set the key to: _liveDomain.com_

   ```xml

   <add key="CMSUrlHost" value="liveDomain.com" />

   ```
3. Save the file.

<!-- dev-model:mvc end -->

## Setting the site's Presentation URL

Configure the **Presentation URL** property (via the **Sites** application) of the front-end site to target the public domain provided by the proxy server:

1. Open the Xperience administration interface in your browser.
2. Navigate to the **Sites** application and edit the site.
3. Set the **Presentation URL** property to the full domain name of the proxy server.
   - For example, assuming the site is running behind the _https://liveDomain.com_ proxy server, set _Presentation URL_ to: _https://liveDomain.com_
4. **Save** the changes.

The system is now configured to generate URLs targeting the specified proxy server.

## Licensing and domain aliases in proxy scenarios

If you need to access the Xperience application through a different domain than the proxy server's public domain (for example a back end server domain in a local development or testing environment), you also need to add:

1. A valid [license](https://docs.kentico.com/13/configuring-xperience/managing-sites/managing-site-license-keys.md) for the given domain.
2. [Domain aliases](https://docs.kentico.com/13/configuring-xperience/managing-sites/setting-domain-names-for-sites.md) for your site.
