Run Xperience by Kentico behind a proxy server
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), 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) policies when performing certain actions.
To correctly configure Xperience running behind a proxy service, you need to:
- Set up Forwarded Headers Middleware for your Xperience application.
- Consider domain alias requirements.
Setting up Forwarded Headers Middleware
See the Configure ASP.NET Core to work with proxy servers and load balancers article to learn about Forwarded Headers Middleware.
The following example shows basic forwarded headers configuration in a .NET application’s startup class (Program.cs).
...
// 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.
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 Domain aliases for your website channel.