具有子域的NGINX中的Access-Control-Allow-Origin

时间:2017-03-27 04:44:45

标签: wordpress nginx

我有以下NGINX配置(服务器1)和/ private是wordpress安装:

location /private/ {
  include cloudflare;
  add_header Access-Control-Allow-Origin private.domainofserver2.com;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header X-Forwarded-Proto https;
  proxy_pass http://private.domainofserver2.com/;
}

当我访问https://domainofserver1.com/private时,我的控制台出现以下错误

因此,

Access to Font at 'https://private.domainofserver2.com/wp-content/themes/entrada/vendors/font-awesome/fonts/fontawesome-webfont.woff2?v=4.4.0' from origin 'https://private.domainofserver1.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://domainofserver。com'不允许访问。

我的Wordpress(服务器2)配置是:

# Allow access from all domains for webfonts.
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

如何解决我的错误,因为上述方法不起作用

0 个答案:

没有答案