Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple nginx/webdav setup for use with things like mobile-org
#!/bin/sh
# on ubuntu: need some utils & dev libs
sudo apt-get install apache2-utils openssl libssl-dev libpcre3-dev
# compile nginx
cd /tmp
curl http://nginx.org/download/nginx-0.7.64.tar.gz | tar xz
cd nginx*
./configure --with-http_ssl_module --with-http_dav_module \
--prefix=$HOME/nginx
make && make install
# generate an htpasswd file
htpasswd -c ~/.htpasswd $(whoami)
# ssl
openssl genrsa 1024 > ~/nginx/conf/server.key
openssl req -new -x509 -nodes -sha1 -days 365 \
-key ~/nginx/conf/server.key > ~/nginx/conf/server.crt
# configure
cat > ~/nginx/conf/nginx.conf <<EOF
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
ssl_certificate server.crt;
ssl_certificate_key server.key;
auth_basic "Restricted";
auth_basic_user_file $HOME/.htpasswd;
dav_methods put delete mkcol copy move;
dav_access user:rw;
create_full_put_path on;
server {
listen 1080;
listen 1443 ssl;
location ~ ^/org(/.*)?$ {
alias $HOME/org/mobile\$1;
}
}
}
EOF
# now you can start nginx
~/nginx/sbin/nginx
# and then sync w/ org-mobile-push/pull & mobileorg sync
# URL: http://<my-nginx-ip-addr>:1080/org/index.org
# or use
# URL: https://<my-nginx-ip-addr>:1443/org/index.org
# and your username and password you used above for htpasswd
@svanscho

This comment has been minimized.

Copy link

svanscho commented Jul 16, 2014

There is also a dependency on "gcc" and "make" which is not installed by default.

A fix would be to change line 4 to look like this:
sudo apt-get install apache2-utils openssl libssl-dev libpcre3-dev make gcc

@shaiguitar

This comment has been minimized.

Copy link

shaiguitar commented Jun 28, 2015

Simple note here for webdav setups, you'll probably also want:

dav_ext_methods propfind options;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.