2014-01-22 3 views
0

나는 두 대의 서버 앞에 Nginx로드 밸런서를 가지고있다./admin으로 시작하는 모든 것을 관리 서버로 보내려면/web로 시작하는 모든 항목,/api로 시작하는 모든 항목을 api 서버로 보내려면 URL을 다시 쓰고 있습니다.Nginx 프록시/이미지에서/web/image로

/image로 시작하는 항목을/web/image로 다시 작성하고 싶습니다. 여기

지금까지 내 설정이다 : 나는 webserver1.com/web/image에있는 크기 조정 이미지에 대한 API를 가지고

upstream api-cluster { 
    ip_hash; 
    server apiserver1.com; 
} 

upstream web-cluster { 
    ip_hash; 
    server webserver1.com; 
} 

upstream admin-cluster { 
    ip_hash; 
    server adminserver1.com; 
} 

server { 
    listen 443 ssl spdy; 
    server_name myloadbalancer.com; 
    keepalive_timeout 70; 

    ssl     on; 
    ssl_certificate  /etc/ssl/foo.crt; 
    ssl_certificate_key /etc/ssl/foo.key; 

    location /api { 
    proxy_pass http://api-cluster; 
    } 

    location /web { 
    proxy_pass http://web-cluster; 
    } 

    location /admin { 
    proxy_pass http://admin-cluster; 
    } 

    location/{ 
    deny all; 
    } 
} 

, 예를 들어, URL :

webserver1.com/web/image/foo.png?width=300&height=150 

이를 다시 작성하는 방법 :

myloadbalancer.com/image/foo.png?width=300&height=150 

웹 서버 URL로?

답변

0

/image/foo를/web/image/foo로 변환 한 다음 proxypass로 변환하여 webserver1.com으로 보낼 수 있습니다. 다음과 같은 것 : (테스트 안 함)

location /image { 
    rewrite ^/image /web/image break; 
    proxy_pass http://web-cluster; 
}