Long ago, Dropbox provided a Public folder that had some special capabilities. Those capabilities are now better integrated into Dropbox, but I still use my Public folder for things I intend to share.
I set up a server to make that folder available over the web. I can now share links directly to files, avoiding Dropbox’s web interface altogether, and I don’t have to sign up for a third-party service like Droplr or CloudApp.
The following Dropbox installation instructions are based on these directions from Dropbox itself and this post from Ben Hedrington; they apply specifically to Ubuntu 12.04, but will likely work on other Ubuntu versions and common Linux distros.
Determine whether you’re running 32 or 64 bit Linux (
uname -m). Then, run the applicable command to get Dropbox onto the server:
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
And we’ll need this Python script to manage Dropbox:
cd /usr/local/bin sudo wget "https://www.dropbox.com/download?dl=packages/dropbox.py" sudo mv download\?dl=packages%2Fdropbox.py dropbox sudo chmod +x dropbox
Run the Dropbox daemon to link it to your account:
dropboxd will tell you “This client is not linked to any account…”. Follow its instructions to copy and paste a URL into your web browser to authorize access. Once Dropbox is connected, you can kill it with CTRL-c.
Grab the contents of this init script and put them a file called
"user1 user2", on line 14, with
"your_linux_username", not your Dropbox username. Make the init script executable, and make it start on boot:
sudo chmod +x /etc/init.d/dropbox sudo update-rc.d dropbox defaults
Check if Dropbox is running, and start it if necessary:
sudo service dropbox status sudo service dropbox start
Dropbox will, by default, sync your entire Dropbox folder onto your server. This probably isn’t what you want, especially if you use Camera Upload.
cd ~/Dropbox and use
dropbox ls to see what’s there. Then, for every top-level folder you don’t want on the server, run
dropbox exclude add folder-name.
Now that Dropbox is set up and syncing (congrats!), let’s serve up your
~/Dropbox/Public folder via everyone’s favorite HTTP server. For this part, I’ll assume you have a domain (
dropbox.dzombak.com in this example) with an A record pointed to this VPS.
This is very straightforward: just drop this nginx config into
/etc/nginx/sites-available. Replace all instances of my domain name and Linux username with yours.
If you want, you could change the
autoindex directive on line 14 to expose a directory index of your Public folder.
Link to this configuration from
/etc/nginx/sites-enabled, reload your configuration with
/etc/init.d/nginx reload, and you’re all set.
I wrote a simple AppleScript that works with Quicksilver to generate and copy public links for files hosted using this mechanism.