SiteGround CDN Issues
There are two main types of issues that can occur for SiteGround users who are also using KeyCDN. These are:
404 Not Found
or500 Internal Server Error
caused by anX-Forwarded-Host
(XFH) issue.- Problems pertaining to captchas, warnings in Google Search Console, etc caused by SiteGround's anti-bot AI.
The article will go over both issues as well as point you in the right direction on how to solve them.
1. X-Forwarded-Host
header issue
Certain KeyCDN users who use SiteGround as a hosting provider may experience 404
errors due to a discrepancy between the use of the XFH header sent by KeyCDN and SiteGround. Therefore, additional settings must be configured in order for both to work together. Although it may look like these 404
errors are coming from KeyCDN, they are in fact coming from your origin server (in this case SiteGround), because the request is being proxied through the KeyCDN edge servers.
Why use the X-Forwarded-Host
header?
The X-Forwarded-Host
header is useful for forwarding the original Host
header value to the origin server. This lets the origin server know exactly which hostname the request is coming from instead of just providing you with the standard Host
header value.
The X-Forwarded-Host
header is also useful in the event that you want to manage multiple websites with one KeyCDN Zone.
However, in order to properly configure the headers sent via the KeyCDN edge server and your SiteGround hosting, the following must be done.
What you need to do
In order to fix the 404
issue caused by the XFH header, you'll need to open a ticket with SiteGround directly. Inform their support team that the KeyCDN edge servers are sending the X-Forwarded-Host
header and that you are experiencing 404
errors from SiteGround when trying to access your CDN assets.
The SiteGround support team will need to configure your server in order to properly accept the XFH header. Although each snippet may differ depending on your current setup, SiteGround has provided the following example code which has resolved the issue on their end in the past. This gets added to the Nginx SSL vhost for your domain.
listen youripaddress ssl spdy;
server_name yourservername;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
We have also seen another solution work that may have been related to the use of wildcard subdomains. The second option below creates a symlink from the subdomain to the root folder (e.g. cdn
-> ./
). The symlink must be created in the following folder /home/youraccountname/public_html/yourwebsite
. To create the symlink, you can do so via SSH and use the following snippet, which may vary depending on your setup.
ln -s . cdn
Once the appropriate snippet has been added to your SiteGround server setup, you should be able to test that everything is working correctly with a curl command:
curl -I 'https://yourdomain.com/path/to/an/asset/style.css' -H 'Host: yourdomain.com' -H 'X-Forwarded-Host:yourdomain-hexid.kxcdn.com'
Replace the placeholder values with your actual domain name and KeyCDN Zone URL. Once you run this command in the terminal, you should receive a 200
status, which means the issue is now resolved. If you don't yet receive a 200
status, please double check SiteGround's configuration snippet as it may need to be modified depending on your current server setup.
2. Anti-bot issue
SiteGround introduced an AI-based bot prevention system that helps prevent brute force attacks. However, sometimes this system produces false-positives on KeyCDN requests. This can result in SiteGround captchas, unauthorized warnings from Googlebot in Google Search Tools, and file mime type issues.
If you're experiencing these types of issues, you can either try disabling the anti-bot technology on SiteGround's end or enabling KeyCDN's Origin Shield feature. The Origin Shield server IPs have been whitelisted by SiteGround and should resolve these problems.