Running Xperience behind a proxy server
If you wish to host Xperience behind a proxy server or some other service that masks the application's original 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 (such as uploading images to Media libraries).
To correctly configure Xperience running behind a proxy service, you need to:
- Set up Forwarded Headers Middleware for your live site project. See the Configure ASP.NET Core to work with proxy servers and load balancers article.
- Set the CMSUrlHost configuration key for the live site application
- Configure the site's Presentation URL property
Setting the CMSUrlHost configuration key
In the live site application, set the CMSUrlHost configuration key to the host component of the proxy server's URL (omitting the port number).
- Edit your live site project's web.config file.
Add the CMSUrlHost key into the <appSettings> 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://my.proxyserver.com proxy server, set the key to: my.proxyserver.com
<add key="CMSUrlHost" value="my.proxyserver.com" />
- Save the file.
- Edit your live site project's configuration file (appsettings.json by default).
Add the CMSUrlHost key and set its 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://my.proxyserver.com proxy server, set the key to: my.proxyserver.com
"CMSUrlHost": "my.proxyserver.com",
- Save the file.
Setting the site's Presentation URL property
Configure the Presentation URL property (via the Sites application) of the front-end site to target the proxy server's domain:
- Open the Xperience administration interface in your browser.
- Navigate to the Sites application and edit the site.
- Set the Presentation URL property to the full domain name of the proxy server.
- For example, assuming the site is running behind the https://my.proxyserver.com proxy server, set Presentation URL to: https://my.proxyserver.com
- For example, assuming the site is running behind the https://my.proxyserver.com proxy server, set Presentation URL to: https://my.proxyserver.com
- Save the changes.
The system is now configured to generate URLs targeting the specified proxy server.