Running Kentico behind a proxy server

If you wish to host Kentico 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).

Hotfix 12.0.35 required

To configure Kentico running behind a proxy server using this approach, you need to have hotfix 12.0.35 or newer installed.  

Configuring Kentico running behind a proxy server

The configuration slightly differs based on your project’s development model:

Configuring Portal Engine projects

For Portal Engine projects, set the CMSUrlHost web.configkey to the host component of the proxy server’s URL (omitting the port number): 

  1. Edit your Kentico project’s web.config file.

  2. 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, add the CMSUrlHost key with the my.proxyserver.com value to the <appSettings> section of the Kentico project’s web.config file:
    
    
    
     <add key="CMSUrlHost" value="my.proxyserver.com" />
    
    
     
  3. Save the web.config file.

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

Configuring MVC projects

For MVC projects, you need to:

  1. Set the CMSUrlHost web.config key for the live site MVC application
  2. Configure the MVC site’s Presentation URL property

Setting the CMSUrlHost web.config key

On the MVC live site, set the CMSUrlHost web.configkey to the host component of the proxy server’s URL (omitting the port number).

  1. Edit your MVC project’s web.config file.

  2. 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" />
    
    
     
  3. Save the web.config file.

Setting the MVC site’s Presentation URL property

Configure the Presentation URL property (via the Sites application) of the front-end MVC site to target the proxy server’s domain:

  1. Open the Kentico administration interface in your browser.
  2. Navigate to the Sites application and edit the MVC 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://my.proxyserver.com proxy server, set Presentation URL to https://my.proxyserver.com.
  4. Save the changes.

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