我在Apache Load Balancer后面有2个应用程序节点,看起来像这样:
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/
通过IP单独访问实例时,该字体会正常加载。但是,从负载平衡器访问似乎有一个跨域问题:
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.
我尝试在节点上设置标题和负载平衡器的httpd.conf如下:
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>
并在所有情况下重新启动Apache。似乎不起作用。非常感谢您的帮助。
预先感谢。
将以下内容添加到资产提供商的.htaccess实际上已经解决了它,但必须清除浏览器缓存...-.-
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>