I am using Debian 7 and Nginx 1.2.1. Http headers module is enabled by default with Debian packets (https://wiki.debian.org/Nginx).
I am trying to add links to facebook, twitter and google plus accounts using their given links (with images hosted on their side). Problem is that my browser does not display these 3 images. I were using Apache before and had the module and instruction Header set Access-Control-Allow-Origin "*"
in my site config.
I moved to Nginx and cannot manage to get the equivalent working with the following configuration. I also have Naxsi enabled, using a set of generic rules for wordpress.
No error logs, no idea where to inspect to find the beginning of an answer. All that I found on the internet are these similar questions with similar answers, unfortunately for me (e.g. How do I add Access-Control-Allow-Origin in NGINX?).
server {
listen 192.0.2.3:80;
server_name blog.example.com;
root /blog/example;
index index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
add_header 'Access-Control-Allow-Origin' '*';
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
if ($request_method !~ ^(GET|POST|HEAD)$ ) {
return 444;
}
# location ~* \.(ttf|ttc|otf|eot|woff)$ {
# add_header 'Access-Control-Allow-Origin' '*';
# }
}
Also, curl -I blog.example.com
displays (missing the header directive for cross-origin ?)
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 28 May 2015 06:59:26 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.4.39-0+deb7u2
X-Pingback: http://blog.example.com/abc
I need to recompile Nginx in order to add some other modules and was wondering if headers more could help (https://github.com/openresty/headers-more-nginx-module), though http headers module should be enough apparently.
Thanks for your support.
EDIT 1:
Just realised I was completely wrong and actually did not get it. It is about loading fonts from another domain. In my browser console, I can see I am loading the fonts from another domain (that are not displayed in my browser). No error, I get http code 200, and yet 0KB downloaded (so nothing to be displayed) and when I open the file in a new tab, I can download the content (so it is actually available).