码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 解决图片跨域问题

时间:2019-08-23 17:33:55      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:clu   ram   www   stc   cache   fast   string   usr   error   

server {
listen 80;
server_name files.ascotprime.com ;
root /var/www/ascotprime/UploadFiles/api;
index index.php index.html index.htm;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ ..(gif|jpg|jpeg|png|bmp|swf)$ {
add_header Access-Control-Allow-Origin
;
add_header Access-Control-Allow-Methods ‘GET, POST, OPTIONS‘;
add_header Access-Control-Allow-Headers ‘DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,lang,access-token‘;
if ($request_method = ‘OPTIONS‘){
return 204;}

    }

location ~ \.php {
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods ‘GET, POST, OPTIONS‘;
    add_header Access-Control-Allow-Headers ‘DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,lang,access-token‘;
    if ($request_method = ‘OPTIONS‘) {
        return 204;
    }

    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index /index.php;
    fastcgi_split_path_info        ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include                       fastcgi_params;
}
error_log /usr/local/nginx/logs/error.files.ascotprime.com.log;
access_log /usr/local/nginx/logs/access.files.ascotprime.com.log;

}

nginx 解决图片跨域问题

标签:clu   ram   www   stc   cache   fast   string   usr   error   

原文地址:https://blog.51cto.com/13293070/2432044

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!