apachecross-domainload-balancingfont-facecross-domain-policy

Cross domain issue with font-face and Apache load balancer


I have 2 application nodes behind an apache load balancer which looks like this:

    ProxyRequests off
<Proxy balancer://webfarm>
    BalancerMember http://192.168.1.14:80
    BalancerMember http://192.168.2.15:80
    ProxySet lbmethod=byrequests
</Proxy>

<Location /balancer-manager>
    SetHandler balancer-manager
</Location>
ProxyPass /balancer-manager !
ProxyPass / balancer://webfarm/

When accessing the instances individually by IP, the font is loaded normally. However accessing from the load balancer there seems to be a cross domain issue:

Access to Font at 'http://192.168.1.14/fonts/open-sans/OpenSans-Bold.ttf' from origin 'http://192.168.10.10' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.10.10' is therefore not allowed access.

I have tried setting headers on both nodes and the httpd.conf of the load balancer as follows:

AddType application/x-font-ttf           ttc ttf
AddType application/x-font-otf           otf
AddType application/font-woff            woff
AddType application/font-woff2           woff2
AddType application/vnd.ms-fontobject    eot

<FilesMatch ".(eot|ttf|otf|woff|woff2)">
  Header set Access-Control-Allow-Origin "*"
</FilesMatch>

And restarted apache on all instances. Doesn't seem to work. Your help is much appreciated.

Thanks in advance.


Solution

  • Adding the following to the .htaccess of the asset provider actually solved it, but had to clear the browser cache... -.-

    AddType application/x-font-ttf           ttc ttf
    AddType application/x-font-otf           otf
    AddType application/font-woff            woff
    AddType application/font-woff2           woff2
    AddType application/vnd.ms-fontobject    eot
    
    <FilesMatch ".(eot|ttf|otf|woff|woff2)">
      Header set Access-Control-Allow-Origin "*"
    </FilesMatch>