Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to separate our application server from our website gallery storage. I have an application server on and gallery server with all the images on . Now I want to make it so every time request comes into server with the ending of *.jpeg and/or beginning of, would get redirected to

I have checked a second server and it is working perfectly fine.

Now the on the 1st server i tried doing :

location /uploads {

but it doesn't seem to work.

Any1 has any experience with this kind of situation in Nginx ? Or could some1 point me to the right direction ? Much appreciated.

share|improve this question
Do you want to redirect the client, or do you want to transparently proxy their request? – Shane Madden Mar 8 '12 at 4:58
I want to redirect a client. Well the idea is that while client is browsing, the picture requests comes from different domain. Also id user is uploading pictures it uploads it to that domain. – Katafalkas Mar 8 '12 at 8:33
Is it basis of a load balancing I an talking about ? – Katafalkas Mar 8 '12 at 8:36

2 Answers 2

Sorry, I did not see your comment above. To make redirections on client-side this can be useful :

server {



    rewrite ^/uploads/(.*)$$1        permanent;
    rewrite ^/(.*)\.jpg$$1.jpg    permanent;



Nginx returns an 'HTTP 301 Moved permanently' response on every request that matches a rewrite pattern. This way the browser redirects to the new location (and is aware of), according to the content of the 'Location:' HTTP response header.

share|improve this answer
Cheers, I will test it out maybe this weekend, will give you heads up when I get results – Katafalkas Mar 9 '12 at 14:06

You can resolve this by using a regular expression in the location block :

location ~ ^/uploads/|\.jpg$ {
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.