• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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