- Plesk for Linux
How to set up cross-origin resource sharing (CORS) in Plesk to allow example.org to get resources from example.com?
Note: CORS is supported in the following browsers: Chrome 3+, Firefox 3.5+, Opera 12+, Safari 4+, Internet Explorer 8+
Warning: Only one "Access-Control-Allow-Origin" is possible to be added. For Nginx, it's required to choose if it has to be HTTP or HTTPS. And won't work if set in Nginx and in Apache.
Log in to Plesk on the server, where domain example.com is hosted.
Navigate to the tab Domains > example.com > Apache and nginx settings and add the following directives to the section Additional directives for HTTP:
CONFIG_TEXT: Header set Access-Control-Allow-Origin "http://example.org"
Additional directives for HTTPS:
CONFIG_TEXT: Header set Access-Control-Allow-Origin "https://example.org"
In case nginx as reverse proxy is enabled, add the following nginx directive to Domains > example.org > Apache and nginx settings > Additional nginx directives, depending on whether website works via HTTP or HTTPS :
CONFIG_TEXT: add_header 'Access-Control-Allow-Origin' 'http://example.org';
CONFIG_TEXT: add_header 'Access-Control-Allow-Origin' 'https://example.org';
Click Apply to save settings.