font-face 和 Apache 负载均衡器的跨域问题
Cross domain issue with font-face and Apache load balancer
我在 apache 负载均衡器后面有 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 上设置 headers,如下所示:
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。似乎不起作用。
非常感谢您的帮助。
提前致谢。
在asset provider的.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>
我在 apache 负载均衡器后面有 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 上设置 headers,如下所示:
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。似乎不起作用。 非常感谢您的帮助。
提前致谢。
在asset provider的.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>