NGINX 크로스 도 메 인 요청 설정 지원

1585 단어

location ^~/api/v1 {
        add_header'Access-Control-Allow-Origin'"$http_origin";
        add_header'Access-Control-Allow-Methods''GET, POST, PUT, DELETE, OPTIONS';
        add_header'Access-Control-Allow-Headers''DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type    ';
        add_header'Access-Control-Allow-Credentials''true';
        if($request_method='OPTIONS') {
                add_header'Access-Control-Allow-Origin'"$http_origin";
                add_header'Access-Control-Allow-Methods''GET, POST, PUT, DELETE, OPTIONS';
                add_header'Access-Control-Allow-Headers''DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type    ';
                add_header'Access-Control-Allow-Credentials''true';
                add_header'Access-Control-Max-Age'1728000;# 20  
                add_header'Content-Type''text/html charset=UTF-8';
                add_header'Content-Length'0;
                return200;
        }

#               ,                

        proxy_passhttp://127.0.0.1:8085;

        proxy_set_headerHost$host;

        proxy_redirectoff;

        proxy_set_headerX-Real-IP$remote_addr;

        proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;

        proxy_connect_timeout60;

        proxy_read_timeout60;

        proxy_send_timeout60;

}

좋은 웹페이지 즐겨찾기