Fonts - Access-Control-Allow-Origin
February 13, 2017 10:52AM
Hi everyone,

I need to authorize the BODY for the .ttf .eot .woff files.
I tried different solutions, but nothing works.
When I put this on my server configuration:

location ~ \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin "*";
}

I get a 404 error on the file.

When I put this in the first Location I have no more 404 error but still CORS
if ($request_filename ~* .(eot|ttf|woff)$){
add_header Access-Control-Allow-Origin "*";
}

server {
listen 443 ssl;
server_name www.xxx.xx;
root /home/www/public;
index index.php index.html index.htm;

client_body_buffer_size 10M;
client_max_body_size 10M;

location / {
try_files $uri $uri /app.php?$args;

rewrite ^/templates/([^/]+)/(?:[0-9]+)(?:(?:\.[0-9]+)+)?/(.*)$ /templates/$1/$2 break;

}

location ~^/api/([0-9]+\.[0-9]+)/ {
try_files $uri $uri /api.php?$args;
}

location ~ ^/(app|api)\.php(/|$) {
fastcgi_pass php-stream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_read_timeout 60;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;

internal;
}

location ~ \.php$ {
return 404;
}
}

Can you help me?
Thank you.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 164
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready