- Configure the proxy in your external environment.
- Confirm that the configuration is correct.
- Added the domain to HubSpot to enable content publishing.
Before you begin
Review the prerequisite sections below for guidance applicable to all providers, along with Cloudflare-specific information if you’re setting up a reverse proxy using Cloudflare’s Orange-to-Orange (O2O) configuration.General prerequisites
Before proceeding, ensure you’ve reviewed the reverse proxy overview to:- Confirm a reverse proxy is the right solution for your use case.
- Understand how reverse proxies work with HubSpot.
- Review the considerations and trade-offs.
- Verify you meet the prerequisites, including having a CDN or distributed computing environment.
Cloudflare prerequisites
A Cloudflare Enterprise account is required to set up an Orange-to-Orange (O2O) reverse proxy configuration for HubSpot.
Check for Cloudflare zone holds
Cloudflare’s zone hold feature is a security setting that prevents other Cloudflare zones from adding a customer’s domain. If zone hold is enabled on your domain, HubSpot’s hostname validation will fail — even after you add the proxy CNAME record. This is because the zone hold blocks the hostname from being validated through Cloudflare’s infrastructure. To check if zone hold is enabled:- Log in to your Cloudflare account.
- Navigate to the zone for your domain.
- Go to Overview or check your account-level security settings.
- Look for the Zone Hold setting. If it is enabled, you must disable it before proceeding with the reverse proxy setup.
Understand hostname verification with Cloudflare O2O
With a standard reverse proxy (e.g., nginx or Apache), you can typically pre-verify a hostname before making DNS changes using a TXT or HTTP validation token. This is not possible when your domain is already on Cloudflare. When your domain is managed by Cloudflare:- Hostname pre-validation via TXT or HTTP token is not supported for O2O custom hostnames. Cloudflare detects that the domain is already on their network and requires DNS-based activation instead.
- The hostname will only be verified once a proxied (orange-clouded) CNAME record is added pointing to the appropriate HubSpot zone.
- If your domain is currently hosted elsewhere and you attempt to use a reverse proxy like nginx or Apache to forward requests to HubSpot’s zone, this will not work and will result in an error.
- The only way to activate the hostname is to add the orange-clouded CNAME record pointing to your HubSpot zone.
General instructions
The steps below provide high-level guidance across all providers. It’s recommended you review each of the sections below, then proceed with the provider-specific instructions tailored to specific third-party providers, if applicable.Configure the proxy
Adding a custom reverse proxy means that users of your website will make a request to your service, then be proxied through to HubSpot’s CDN. To begin setting up the proxy, first configure it in your external environment, such as a CDN like Amazon CloudFront or Cloudflare, or an nginx server.You should always implement the proxy in a load balanced environment so that traffic from your proxy rotates requests to the HubSpot origin domain from multiple IP addresses.
<HubID>.<suffix>. The suffix value is determined by your account’s assigned data center. For accounts on the US East (NA1) data center, you’ll also need to append a number to the suffix, based on the last two digits of your Hub ID.
Use the tables below to find the correct suffix along with the correct numbers to include in the suffix.
Suffixes by data center
Suffix numbers by Hub ID (US East only)
For accounts on the US East (NA1) data center, append a number to the suffix based on the last two digits of your Hub ID.
For example, if your Hub ID is
123456 and is hosted in the US East data center, the correct origin domain would be 123456.sites-proxy.hscoscdn00.net.
Once you’ve noted the correct domain to use, continue reading for general instructions for configuring a reverse proxy, as well as specific guidance for nginx, Amazon CloudFront, or Cloudflare.
In general, you can configure your proxy to forward requests using your origin CNAME and adding the following configuration settings:
- Set your proxy to perform no caching for paths originating from HubSpot. HubSpot automatically manages the content of our CDN’s cache so pages are updated automatically when content is published. Note that if the service caches responses, pages may not update for hours or days.
- Add or prepend to a
X-Forwarded-For header with the client IP address of the original requestor. This is required to differentiate clients from each other. Many services such as CloudFront maintain these headers automatically. - To ensure personalized content based on location works, pass a static header of
X-HubSpot-Trust-Forwarded-For: true. This will trust theX-Forwarded-Forheader, which may not have been updated by all upstream proxies. - Pass a
X-HS-Public-Host header with a value of your destination domain. - Allow all HTTP methods.
- Ensure an SSL certificate is provisioned and installed for your proxy domain.
- Forward all query strings.
- Forward all other request and response headers as-is, including cookies.
- Ideally, all paths under your domain should proxy to HubSpot. If that’s not the case, then the following paths must proxy so assets load properly from your domain:
/_hcms/*/hs/*/hubfs/*/hs-fs/hubfs/*/hs-fs/*/cs/c/*/e3t/*/events/*
The
hs-fs/hubfs/* path was added as of December 20, 2024, and replaces the hs-fs/hub/* path. Your reverse proxy configuration should allow for the new path, and you may want to update any hard-coded references to the old path to avoid redirects. Learn more in the developer changelog.Confirm the configuration is correct
You can identify configuration issues in your HubSpot domain settings:- In your HubSpot account, click the settings icon in the main navigation bar.
- In the left sidebar menu, navigate to Website > Domains & URLs.
- Next to the domain you are using for your reverse proxy, click the Edit dropdown menu and select Verify Reverse Proxy Connection.
- Click any category that is labeled as Failed to view recommendations for fixing the issue.
- Once you’ve implemented your fixes, click Refresh test to check your configuration again.
https://[yourFullDomain]/_hcms/diagnostics and verify the following information:
- The current time value changes on every load. This confirms that the page is not cached.
- The
User-Agentis consistent with your browser. - The
Accept-Languagevalue is consistent with your browser. - The
Accept-Encodingheader is*. This ensures that responses are compressed. - The
Cookievalue is not blank. - The
Protocolishttps. - The leftmost IP address in
X-Forwarded-Formatches your IP address as reported by a service like https://www.whatismyip.com. - The
IP-Determined Locationvalues are accurate to your location. These are based on the IP-related headers inX-Forwarded-For.
Add the domain to HubSpot
With your proxy configured, you’ll then add your domain to HubSpot. You will not be fully connecting the domain to HubSpot in the way that you would in the standard domain connection process. Rather, you’ll start the connection process to make the domain available for publishing HubSpot content, but you will not create CNAME records in your DNS provider. By the end of this process, your proxy will receive all requests to the domain and can choose to proxy certain paths to HubSpot and other paths to other content hosts. To add your domain to HubSpot:- In your HubSpot account, navigate to your domain settings.
- Click Connect a domain.
- Select Primary or Secondary. Redirect and email sending domains are not supported for this feature.
- Click to toggle the Connect with HubSpot’s built-in content delivery network (CDN) switch off, then click Connect.
- Select the content type you’ll be hosting on the domain, then click Next.
- Enter the brand domain. For example, for www.website.com, you would enter website.com. This domain must match the domain being requested through your reverse proxy.
- Enter the subdomain that you’ll be hosting content on. The subdomain needs to match the subdomain for the externally hosted domain. Then click Next.
- Review the domain you’ve entered, then click Next.
-
Next, verify your domain so that HubSpot can confirm your domain ownership and allow content publishing:
- In your DNS provider, create the records using the provided values.
- In HubSpot, click Verify. It can take up to 4 hours for HubSpot to recognize changes made to your DNS provider and verify your hostname.
Provider-specific instructions
While you can use the general instructions above to set up your proxy, below are steps for setting up a reverse proxy with Amazon CloudFront, nginx, or Cloudflare specifically.Set up a reverse proxy in Amazon CloudFront
To set up a reverse proxy in Amazon CloudFront, you’ll need to create a new distribution with a new alternate domain name, create a new origin, then create cache behaviors for the page paths where your HubSpot content is hosted. You can learn more about working with distributions in the AWS documentation.- Log in to your Amazon CloudFront account.
- In the left sidebar, navigate to Distributions.
-
If you’re starting from scratch, you’ll first need to create a new distribution by clicking Create Distribution. Alternatively, you can edit an existing distribution or skip to the origin and behaviors setup steps.
- On the General tab, click Edit.
- In the Alternate Domain Names (CNAMEs) field, add the domain, including the subdomain. This must match the domain you added to HubSpot.
- Confirm your changes by clicking Yes, Edit. You’ll then be directed back to the General tab where your domain should now be listed next to Alternate Domain Names (CNAMEs).
- You’ll also need to create a new CNAME record in your DNS provider using the value from the Domain Name field. This value should look something like
<value>.cloudfront.net.
-
Next, set up a new origin:
- Click the Origins and Origin Groups tab.
- Click Create Origin, then set up your origin:
- In the Origin domain field, enter the
<HubID>.<suffix>domain value from the table above. This value should look something like123.sites-proxy.hscoscdn20.net. - Under Add custom header, click Add header. Then, add the following header details:
- To ensure personalized content based on location works, either pass a
X-Client-IPheader with a value of the end user’s IP (preferred) or pass a static header ofX-HubSpot-Trust-Forwarded-For: true. The latter will trust theX-Forwarded-Forheader, which may not have been updated by all upstream proxies. - Pass a
X-HS-Public-Hostheader with a value of your destination domain.
- To ensure personalized content based on location works, either pass a
- In the Origin domain field, enter the
- Click Create to save your changes.
-
Then, set up cache behaviors for the page paths you’ll be hosting HubSpot content on:
- Click the Behaviors tab.
- Click Create Behavior.
- In the Path pattern field, enter the URL path of the page that your HubSpot content is hosted on. This can be a path to a specific page, or a flexible URL such as a wildcard. Learn more about path patterns.
- Click the Origin and Origin Groups field, then select the origin you created earlier.
- Click Save changes.
Set up a reverse proxy using nginx
To configure a reverse proxy with nginx, you’ll need to create a location configuration file that includes SSL information and the location path information. When working with nginx, there are several headers and settings required to route traffic. Below are snippets of a sample nginx location configuration file to use as a starting point.Set up a reverse proxy with Cloudflare (Orange-to-Orange)
After you’ve fully reviewed the Cloudflare-specific prerequisites above, and added your domain to HubSpot, you can proceed with the steps below.1. Configure the CNAME record in Cloudflare
Configure the CNAME record in Cloudflare to point to your HubSpot zone:- Log in to your Cloudflare account.
- Navigate to the zone for your domain.
- Navigate to DNS > Records.
- Click Add record.
- Set the record type to CNAME.
- In the Name field, enter the subdomain you added to HubSpot in the previous step above.
- In the Target field, enter your HubSpot proxy domain (e.g.,
123456.sites-proxy.hscoscdn00.net). - Ensure the Proxy status is set to Proxied (orange cloud). This is critical, as the record must be orange-clouded for the O2O configuration to work.
- Click Save.
2. Configure request header transform rules
With a traditional reverse proxy (e.g., nginx or Apache), required headers are set in your proxy configuration code. With Cloudflare, these headers must be set using request header transform rules (also known as “Modify Request Header” rules). HubSpot requires the following headers to be present on all proxied requests:
To set up the header transform rules:
- In your Cloudflare dashboard, navigate to the zone for your domain.
- Go to Rules → Transform Rules (or Rules → Overview, then click Modify Request Header).
- Click Create rule.
- Give the rule a descriptive name (e.g.,
HubSpot Reverse Proxy Headers). - Under When incoming requests match, set the condition to:
- Field:
Hostname - Operator:
equals - Value: Your domain name (e.g.,
www.example.com)
- Field:
- Under Then, add the following header modifications:
- Set
X-HS-Public-Host: - Action: Set static
- Header name:
X-HS-Public-Host - Value: Your destination domain (e.g.,
www.example.com) - Set
X-HubSpot-Trust-Forwarded-For:- Action: Set static
- Header name:
X-HubSpot-Trust-Forwarded-For - Value:
true
- Set
- Review the rule configuration, then click Deploy.
You do not need to create a transform rule for
X-Forwarded-For. Cloudflare automatically adds this header with the visitor’s IP address for all proxied (orange-clouded) requests. Additionally, Cloudflare’s Request Header Transform Rules do not allow modifying X-Forwarded-For — the backend proxy re-adds it after all rules run.3. Path-based proxying with DNS override (optional)
If you want to serve only specific paths (e.g.,/blog) from HubSpot while keeping the rest of your domain on your existing hosting provider, you’ll need to use a Cloudflare origin rule with a DNS override. This approach uses a dedicated subdomain (e.g., hub.example.com) that points to HubSpot, and an origin rule that routes only specific paths to that subdomain.
This is necessary because when your domain is on Cloudflare, the only way to activate the HubSpot hostname is with a proxied CNAME record. You cannot keep your main domain pointing to your existing provider and simultaneously proxy only certain paths to HubSpot without a separate subdomain.
To set up the origin rule:
- In your Cloudflare dashboard, navigate to the zone for your domain.
- Navigate to Rules > Origin Rules.
- Click Create rule.
- Give the rule a descriptive name (e.g.,
HubSpot /blog proxy). - Under When incoming requests match, set the condition to:
- Field:
URI Path - Operator:
starts with - Value:
/blog(or whatever path(s) you want to proxy to HubSpot)
- Field:
- Under Then, enable DNS override and set the destination to your HubSpot subdomain (e.g.,
hub.example.com). - You may also need to set a host header override to ensure the correct
Hostheader is sent to HubSpot. Set it to your HubSpot subdomain (e.g.,hub.example.com). - Review the rule configuration, then click Deploy.
- A visitor requests
https://www.example.com/blog. - Cloudflare matches the origin rule for the
/blogpath. - The DNS override sends the request to
hub.example.com(which is orange-clouded to HubSpot’s zone). - HubSpot receives the request and serves the content.
- For all other paths (e.g.,
https://www.example.com/about), the request goes to your existing hosting provider as normal.
4. Confirm the configuration is correct
After completing the DNS and header configuration, verify that your reverse proxy is working correctly. Verify in HubSpot domain settings- In your HubSpot account, go to Settings → Website → Domains & URLs.
- Next to your domain, click the Edit dropdown and select Verify Reverse Proxy Connection.
- Click any category labeled Failed to view recommendations for fixing the issue.
- After implementing fixes, click Refresh test to re-check.
- The current time value changes on every load (confirms the page is not cached).
- The User-Agent is consistent with your browser.
- The Accept-Language value is consistent with your browser.
- The Accept-Encoding header is
*(ensures responses are compressed). - The Cookie value is not blank.
- The Protocol is
https. - The leftmost IP address in X-Forwarded-For matches your IP address (as reported by a service like whatismyip.com).
- The IP-Determined Location values are accurate to your location.
X-Forwarded-ForX-HubSpot-Trust-Forwarded-For(should betrue)X-HS-Public-Host(should match your domain)
Troubleshooting
The following sections outline common errors you may encounter during the Cloudflare reverse proxy setup process and recommended ways to fix them. Hostname verification fails
Headers not being received by HubSpot
If HubSpot is not receiving the required headers:
- Verify that your transform rule is deployed and not in draft state.
- Confirm the Hostname equals condition matches your domain exactly (including subdomain).
- Check that you are not overwriting headers with another transform rule that runs later. Cloudflare applies rules in the order they are listed; rules further down the list can override earlier ones.
- Use the headers endpoint to inspect exactly what HubSpot is receiving.
- Ensure your Cloudflare configuration does not cache responses for paths originating from HubSpot. HubSpot automatically manages content caching on its CDN. If Cloudflare caches responses, pages may not update for hours or days.
- Check that no Cloudflare Page Rules or Cache Rules are set to cache everything for your domain.