How to configure nginx as a reverse proxy like this?

i want to use nginx as a reverse proxy.

the back end is some storages. lets say storage1, storage2.

there are two service running in each storage,
one for upload on port 80, and one for download on port 81
so with nginx i want
http://hostname/storage1/upload/filename forward to storage1 port80
http://hostname/storage1/download/filename forward to storage1 port81
http://hostname/storage2/upload/filename forward to storage2 port80
http://hostname/storage2/download/filename forward to storage2 port81

how can i get this?

thx in advance.

Please try:

server_name your_server_name;

location/storage1/upload {
proxy_pass http://storage1:80;

location/storage1/download {
proxy_pass http://storage1:81;
location/storage2/upload {
proxy_pass http://storage2:80;

location/storage2/download {
proxy_pass http://storage2:81;


2008/10/28 yong xue [email protected]