Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm setting my son up so he can manage his simple website by editing a file on dropbox.

My nginx config looks like this:---

server {
        listen 80;
        server_name         name.com *.name.com;
        location / {
                proxy_pass https://dl.dropbox.com/u/12345678/index.html;
        }
}

This works fine for serving the index.html file. The problem is if he puts an img tag in the index.html file that points to a jpeg in the same directory as his index.html file on dropbox. it doesn't get picked up. Is there anyway to do this?

share|improve this question
add comment

closed as off topic by Zoredache, SvW, Tom O'Connor, Michael Hampton, Scott Pack Dec 10 '12 at 18:56

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Break it up into two location blocks. One so that you can be served images (and all other assets) in the root directory, but also telling it to serve images by rewriting it and then proxy passing it. And the other block for serving the index file in the root.

Not tested, but should work.

location / {
   proxy_pass https://dl.dropbox.com/u/12345678/index.html;
}

location ~* \.(jpg|jpeg|gif|png|bmp|ico|css|js) {
   rewrite /(.*) /$1 break;
   proxy_pass https://dl.dropbox.com/u/12345678/;
}
share|improve this answer
    
This gives an error: nginx: [emerg] "proxy_pass" may not have URI part in location given by regular expression, or inside named location,... –  flc Dec 10 '12 at 8:22
    
Whoopsie, forgot that proxy_pass needed a URI part. Updated the answer for you. –  Taylor Jasko Dec 10 '12 at 8:24
    
Thanks, but still giving the same error. –  flc Dec 10 '12 at 8:33
    
Very strange -- quite confused as that should be working. –  Taylor Jasko Dec 10 '12 at 8:54
add comment

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