Knowledgebase
Knowledgebase
LiteSpeed/Apache CORS with CDN
Posted by Will Kruss on 13 January 2020 09:41 AM

To allow the EdgePort CDN integration with the Cloudlets/Jelastic platform if running a .htaccess based webserver such as Litespeed or Apache, you need to enable the CORS policy in the root .htaccess on the site.

The easiest entry is:

################
## CORS policy for CDN

<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods: "*"
Header set Access-Control-Allow-Headers: "Origin, X-Requested-With, Content-Type, Accept, Authorization"
</IfModule>

 

You can also provide a slightly more secure CORS policy by specifying the origin domain e.g.

################
## CORS policy for CDN
<ifmodule
mod_headers.c> SetEnvIf Origin "^(.*\.domain\.com)$" ORIGIN_SUB_DOMAIN=$1 Header set Access-Control-Allow-Origin "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN Header set Access-Control-Allow-Methods: "*" Header set Access-Control-Allow-Headers: "Origin, X-Requested-With, Content-Type, Accept, Authorization" </ifmodule>