【发布时间】:2018-02-23 23:20:42
【问题描述】:
我在 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 上设置标头,如下所示:
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。似乎不起作用。 非常感谢您的帮助。
提前致谢。
【问题讨论】:
标签: apache cross-domain load-balancing font-face cross-domain-policy