Serve very simple static website from dropbox [closed]

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?

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/;
}

Attribution
Source : Link , Question Author : flc , Answer Author : Taylor Jasko

Leave a Comment