---
title: "Serve Servicely behind a reverse proxy"
site: admin
version: 1.11
versions: "all"
url: https://docs-new.servicely.ai/admin/1.11/environments/reverse-proxy/
type: task
application: platform
last_updated: 2026-10-18
commit: 50111ae9bd3b
---


A reverse proxy on your own web servers serves your Servicely instance from your own domain, such as `https://<yourdomain>.com`. This page is for administrators who have set up the proxy and now need Servicely to use the new URL.

A reverse proxy is not a redirect. With a redirect, the browser shows the Servicely URL once the page loads. With a reverse proxy, it keeps showing your URL.

## Before you begin

- You need the `administrator` role.
- Set up and test the reverse proxy first, for example with Apache HTTP Server or NGINX. Follow that product's documentation. You can use a domain or a subdomain, as long as you use the full URL everywhere below.
- Your organisation runs and supports the proxy. If the proxy is down, users cannot reach Servicely through your URL.
- Tell Servicely that you are making this change.
- On a live instance, make the change outside business hours. It changes the base URL and the single sign-on set-up.

## Steps

<Steps>
  <Step>
    Go to **Application → Application → Application properties** and open `system.baseurl`. In **Application properties value**, replace `https://<yourinstancename>.servicely.ai` with your URL, such as `https://<yourURL>`. Save the record.
  </Step>
  <Step>
    If single sign-on is already set up, open the identity provider under **Administration → Authentication → Identity provider**. Clear **Login URL**, **IDP Metadata XML** and **SP Metadata XML**, then save.
  </Step>
  <Step>
    In your identity provider, replace the Servicely URL with yours in the three URLs below. Keep the rest of each URL as it was.

    - Identifier or login: `https://<yourURL>/idp_callback?client_name=`
    - Reply: `https://<yourURL>/idp_callback?client_name=`
    - Logout: `https://<yourURL>/idp_callback?logoutendpoint=true&client_name=`
  </Step>
  <Step>
    Download the metadata from your identity provider. Paste its content into **IDP Metadata XML** on the Servicely identity provider record, save, and test single sign-on.
  </Step>
  <Step>
    Go to **Administration → Business Logic → System configuration scripts** and open "Set initial BaseURL System Property".

    <Image src="asset:screenshots/admin/environments-reverse-proxy/image-2.png" size="38">The System configuration scripts list with the Set initial BaseURL System Property script.</Image>
  </Step>
  <Step>
    Replace the script with the version below. Set `PROD_INSTANCE_BASE_URL` to your Servicely URL and `BASE_DESIRED_PROD_URL` to your proxy URL, then save.

    ```javascript
    // See if the property already exists
    let propertyRecord = ApplicationPropertyManager.getGlobalPropertyRecordByKey("system.baseurl");
    let generatedBaseURL = ApplicationPropertyManager.generateDefaultBaseUrl();

    let PROD_INSTANCE_BASE_URL = "https://<yourinstancename>.servicely.ai"; // Replace with your Servicely URL
    let BASE_DESIRED_PROD_URL = "https://<yourURL>"; // Replace with your reverse proxy URL

    if (propertyRecord == null) {
        // It doesn't exist, so create the property
        ApplicationPropertyManager.createGlobalPropertyRecord(
            SYSTEM_BASEURL_PROPERTY,
            generatedBaseURL,
            "string",
            "The base URL to use for URL construction (e.g. creating external links)"
        );
    } else {
        // The record already exists, so update it to a new value if appropriate
        let currentValue = propertyRecord.Value();

        if (generatedBaseURL == PROD_INSTANCE_BASE_URL) {
            // On production, keep the reverse proxy URL
            if (currentValue != BASE_DESIRED_PROD_URL) {
                propertyRecord
                    .Value(BASE_DESIRED_PROD_URL)
                    .update();
            }
        } else {
            if (currentValue != generatedBaseURL) {
                propertyRecord
                    .Value(ApplicationPropertyManager.generateDefaultBaseUrl())
                    .update();
            }
        }
    }
    ```
  </Step>
</Steps>

The shipped script runs at every node start-up. It resets `system.baseurl` to the instance's own Servicely URL, so without the change in the last step your URL is lost at the next restart. The edited script keeps your URL on production and still resets the URL on any other instance, such as a clone.

If you set up single sign-on after the proxy, use your own URL in the identity provider from the start.

## Result

Servicely builds external links from your URL, and single sign-on returns users to your URL. The base URL survives restarts on production. On a non-production instance cloned from production, the script sets the base URL back to that instance's own address.

## Related

- [Set up single sign-on with Microsoft Entra ID](page:access/sso-microsoft-entra-id)
- [Application Properties](page:platform/application-properties)
- [System configuration scripts](page:automation/system-configuration-scripts)
- [Restrict access by IP address](page:access/ip-filtering)
