Last active
December 20, 2015 16:19
-
-
Save oinopion/6160200 to your computer and use it in GitHub Desktop.
Simple web-dave storage in vagrant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant:$apr1$zpE.it7v$shvcPxMoeK19fXQSGoRql0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
aptitude update | |
aptitude install nginx-full -y | |
mkdir -p /srv/data /var/run/apache2-dav | |
chown www-data:www-data /srv/data /var/run/apache2-dav | |
cat << 'EOF' > /etc/nginx/sites-available/default | |
server { | |
listen 8000; | |
root /srv/data; | |
server_name localhost; | |
location / { | |
autoindex on; | |
dav_methods put delete mkcol; | |
create_full_put_path on; | |
limit_except GET { | |
auth_basic "Vagrant DAV"; | |
auth_basic_user_file /vagrant/htpass; | |
} | |
} | |
} | |
EOF | |
aptitude install apache2 -y | |
a2enmod dav | |
a2enmod dav_fs | |
cat << 'EOF' > /etc/apache2/sites-available/default | |
DavLockDB /var/run/apache2-dav/davlock.db | |
ServerName localhost | |
<VirtualHost *:80> | |
DocumentRoot /srv/data | |
<Location /> | |
Dav on | |
AuthType Basic | |
AuthName "Vagrant DAV" | |
AuthUserFile /vagrant/htpass | |
<LimitExcept GET OPTIONS> | |
Require valid-user | |
</LimitExcept> | |
</Location> | |
LogLevel warn | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
</VirtualHost> | |
EOF | |
service nginx restart | |
service apache2 restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Run 'vagrant up' to start server | |
# Apache will be available at localhost:8000 | |
# Nginx will be available at localhost:7000 | |
# Both share htpass and data directory | |
# To upload file via PUT do: | |
# $ curl 'http://vagrant:vagrant@localhost:8000/hello.txt' -T hello.txt | |
# To create collection do: | |
# $ curl 'http://vagrant:vagrant@localhost:8000/images' -X MKCOL | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "precise32" | |
config.vm.box_url = "http://files.vagrantup.com/precise32.box" | |
config.vm.network :forwarded_port, guest: 80, host: 8000 | |
config.vm.network :forwarded_port, guest: 8000, host: 7000 | |
config.vm.provision :shell, :path => "provision.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment