标签:nginx 跨域acl
nginx跨域访问配置,需要配置多个源域名,有简单的方法,但不安全:
add_header "Access-Control-Allow-Origin" *
以下是我的配置:
<--------nginx config----------->
if ( $http_origin ~* (https?://(.+\.)?(youyuan|uyuan)\.(.*)$) ) { add_header "Access-Control-Allow-Origin" "$http_origin"; } ### add_header Access-Control-Allow-Origin http://*.youyuan.com; ### add_header Access-Control-Allow-Origin http://*.uyuan.info; ### add_header Access-Control-Allow-Origin http://*.youyuan.com.cn; ### add_header Access-Control-Allow-Origin http://*.youyuan.cn; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
<--------nginx config----------->
如果使用3#号里的方法是错误的,会出现如下报错:
标签:nginx 跨域acl
原文地址:http://linuxadmin.blog.51cto.com/2683824/1671269