• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Where to add Access-Control-Allow-Origin *

karadayi

Basic Pleskian
Hi,

Could somebody tell me where I can add the line add_header Access-Control-Allow-Origin *; ?

Code:
location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
         add_header Access-Control-Allow-Origin "*"; 
}

/etc/nginx/nginx.conf ?
 
In your Plesk control panel, go to Websites & Domains (tab) -> Web Server Settings then scroll down to "Additional nginx directives". Place your directive in the text box there.
 
This is not working and gives me a 500 Error

9acf9j8q.jpg
 
@karadayi,

The location directive is defined in a proper fashion, even though you can still try to use parentheses (i.e. "Access-Control-Allow-Origin") (note that it should not make a difference).

The problem is very likely to be present in the lines before the location directive, being the lines concerning gzip.

Note that the gzip ruleset is not really required, it does not always yield the highest page load performance, but let´s not discuss about this.

I would suggest to

a) remove the gzip ruleset completely, in order to test for the correct definition of the location directive, and

b) re-introduce the gzip ruleset, with

- the "#text/html is always compr..... " comment removed,
- the "gzip types" on one line (not multiple lines, as is the case, in your custom nginx configuration)

and that should do the trick.

Kind regards.....
 
Back
Top