Custom origin server
A custom origin server lets you send traffic from one or more custom hostnames to somewhere besides your default proxy fallback, such as:
soap.stores.comgoes toorigin1.comtowel.stores.comgoes toorigin2.com
To use a custom origin server, you need to meet the following requirements:
- Each custom origin needs to be a valid hostname with a proxied (orange-clouded) A, AAAA, or CNAME record in your account's DNS. You cannot use an IP address.
- The DNS record for the custom origin server does not currently support wildcard values.
To use a custom origin, select that option when creating a new custom hostname in the dashboard or include the "custom_origin_server": your_custom_origin_server parameter when using the API POST command.
When using a cloud provider endpoint as a custom origin (for example, Azure App Service, AWS ALB, or GCP Cloud Run), the provider may reject requests with a 404 or 400 error if the Host header does not match a domain configured on that endpoint.
By default, Cloudflare sends the original custom hostname as the Host header. If your cloud provider expects a different hostname:
- Configure the cloud provider to accept the custom hostname as a valid domain, or
- Use an Origin Rule to override the
Hostheader to match the hostname your cloud provider expects.
When Cloudflare establishes a connection to your default origin server, the Host header and SNI will both be the value of the original custom hostname.
However, if you configure that custom hostname with a custom origin, the value of the SNI will be that of the custom origin and the Host header will be the original custom hostname. Since these values will not match, you will not be able to use the Full (strict) on your origins.
To solve this problem, you can contact your account team to request an entitlement for SNI rewrites.
Choose how your custom hostname populates the SNI value with SNI rewrites:
-
Origin server name (default): Set SNI to the custom origin
- If custom origin is
custom-origin.example.com, then the SNI iscustom-origin.example.com.
- If custom origin is
-
Host header: Set SNI to the host header (or a host header override)
- If wildcards are not enabled and the hostname is
example.com, then the SNI isexample.com. - If wildcards are enabled, the hostname is
example.com, and a request comes towww.example.com, then the SNI iswww.example.com.
- If wildcards are not enabled and the hostname is
-
Subdomain of zone: Choose what to set as the SNI value (custom hostname or any subdomain)
- If wildcards are not enabled and a request comes to
example.com, choose whether to set the SNI asexample.comorwww.example.com. - If wildcards are enabled, you set the SNI to
example.com, and a request comes towww.example.com, then the SNI isexample.com.
- If wildcards are not enabled and a request comes to
To set an SNI rewrite in the dashboard, choose your preferred option from Origin SNI value when creating a custom hostname.
To set an SNI rewrite via the API, set the custom_origin_sni parameter when creating a custom hostname:
- Custom origin name (default): Applies if you do not set the parameter
- Host header: Specify
":request_host_header:" - Subdomain of zone: Set to
"example.com"or another subdomain of the custom hostname