-2

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?

1 Answer 1

1

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/;
}
4
  • 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, 2012 at 8:22
  • Whoopsie, forgot that proxy_pass needed a URI part. Updated the answer for you. Dec 10, 2012 at 8:24
  • Thanks, but still giving the same error.
    – flc
    Dec 10, 2012 at 8:33
  • Very strange -- quite confused as that should be working. Dec 10, 2012 at 8:54

Not the answer you're looking for? Browse other questions tagged .