2014-05-15 1 views
0

CORS를 지원하지 않는 일부 API를 사용하기 위해 프록시 서버로 nginx를 사용하려고합니다. 내 설정의 일부 :Nginx를 일반 프록시 서버로 사용

server { 

    listen  8000; 
    server_name localhost; 

    merge_slashes off; 
    resolver 8.8.8.8; 

    location ~ ^/proxy/(.*) { 
     proxy_pass $1; 
    } 
} 

하지만 아무도 또는 잘못된 apiKey에 공급하지 않을 때 나는이 같은 오류가있어 같은 GET 매개 변수를 전달하지 않는 것 :

$ curl -i 'http://localhost:8000/proxy/http://api.rottentomatoes.com/api/public/v1.0/lists.json?apikey=myapikey' 
HTTP/1.1 403 Forbidden 
Server: nginx/1.6.0 
Date: Thu, 15 May 2014 15:33:40 GMT 
Content-Type: text/javascript 
Content-Length: 28 
Connection: keep-alive 
X-Mashery-Error-Code: ERR_403_DEVELOPER_INACTIVE 
X-Mashery-Responder: prod-j-worker-us-east-1c-31.mashery.com 

{"error":"Account Inactive"} 

그리고 난을 proxy_pass documentation을 얻지 못했습니다.

답변

1

내가 $args 수동으로 함께 GET 인수를 전달해야 밝혀 :

server { 
    listen  8000; 
    server_name localhost; 

    merge_slashes off; 
    resolver 8.8.8.8; 

    location ~ ^/proxy/(.*) { 
     proxy_pass $1?$args; 
    } 
} 
관련 문제