Creating a yum/apt/gem repository out of nginx

You can readily convert a nginx installation into a repository for yum, apt, or gems.

Let’s do gems.

Say you have a nginx installation. And so you have a build server churning out gems. Just do an HTTP PUT against a server configured similar to the following:

server {
listen localhost;
client_body_temp_path /tmp;
root /var/www/data/gems;
server_name gems.example.com;
dav_methods PUT DELETE;
create_full_put_path on;
dav_access user:rw group:rw all:r;
client_max_body_size 25M;
}

This allows you to do something like:

curl -T /path/to/gem http://gems.example.com

Then, using incron, cron, or manually, rebuild your gem server’s index:
gem generate_index -d /var/www/html/gems
(but this could have been yum’s createrepo or apt’s equivalent.

Finally, use your gem server in a gem file!

source 'http://gems.example.com'

Gist for configuring the nginx server:

https://gist.github.com/4108841