AnOrigin is where the StackPath CDN retrieves all content for caching from. When content is requested by end-users, but not present on the CDN(aka a cache-miss), the CDN will need to know where your content is located. There are two ways to point the CDN at your Origin, either directly to its IP address, or at a domain that resolves to your Origin.
- Direct IP: Change the IP in the Origin information box on StackPath Control Panel. In this case, you do not need to change DNS if your domain has not changed.
- Domain: Change the DNS A record to resolve to your new IP. In this case, you do not need to change the Origin information if your domain has not changed.
Change via Control Panel
- Log in to the StackPath Control Panel
- Select the CDN tab and click Edit on your desired Site
- Select Origin Settings
- Edit Origin Information, adjust to the new Origin Address and save.
Now the StackPath CDN will send requests for content to the new address in Origin Information.
Change via StackPath API
The following will guide you step-by-step on how to change a single origin through the API. If you have not used the StackPath API yet, read this introduction here to get started.
Step 1: Get your Stack ID
After logging into the control panel and viewing a Stack, the ID is at the end of the URL, which looks like this.
https://control.stackpath.com/stacks/<this-is-your-stack-id>
Step 2: Retrieve a list of Origins
After documenting the stack ID, retrieve a list of Origin IDs that will be needed to update with the Origin IP. All Origin IDs will be listed for the account, so be sure to parse through them to determine which Origin is desired.
curl -H "Authorization: Bearer <token>" -H "Content-type: application/json" "https://gateway.stackpath.com/cdn/v1/stacks/<origin_id>/origins"
Step 3: Update Origin Hostname
This final step will push changes to the Zone configurations. Once submitted, StackPath will immediately redirect Origin pulls to the new IP address or hostname.
- If you're not sure what you should set for Path, set it to your website root '/'.
- The hostname should not include protocol (HTTP, HTTPS)
- Port is your HTTP port, not required. Set to 80 or custom port
- SecurePort is your HTTPS port and is not required. Set to 443 or custom port.
curl https://gateway.stackpath.com/cdn/v1/stacks/{stack_id}/origins/{origin_id}
curl -H "Content-Type: application/json" -H 'authorization: Bearer <token>' -X PATCH https://gateway.stackpath.com/cdn/v1/stacks/<stack_id>/origins/<origin_id> -d '{"path": "string", "hostname": "string", "port": int, "securePort": int}'