[documentation] alpine vm install
I have created script to install etesync server on alpine linux vm. Tested on alpine 3.12. Basically you need to adjust the first 5 variables with your setup. It will automatically generate self signed certificates and serve using nginx. Most importantly, reboot after running this script.
#! /bin/sh
REPO="/home/alpine/etebase"
USER="alpine"
GROUP="alpine"
DOMAIN="etesync.mydomain.com"
PASSWORD="passwd"
## as root
echo -n "Enter root "
su -c "apk add git gcc make musl-dev python3-dev libffi-dev postgresql-dev nginx openssl openrc \
&& openssl req -x509 -nodes -sha256 -subj '/CN=localhost' -newkey rsa:4096 -keyout /etc/ssl/self-signed.key -out /etc/ssl/self-signed.cert -days 3650 \
&& rc-update add nginx \
&& wget -O - https://bootstrap.pypa.io/get-pip.py | python3 \
&& pip install pipenv \
&& tee /etc/nginx/conf.d/default.conf > /dev/null << EOF
ssl_certificate /etc/ssl/self-signed.cert;
ssl_certificate_key /etc/ssl/self-signed.key;
server {
listen 443 ssl;
# listen [::]:443 ssl;
location / {
proxy_set_header Host $DOMAIN;
proxy_pass http://127.0.0.1:8000/;
}
}
EOF"
## as non-root user
cd ~ || exit
git clone https://github.com/etesync/server.git etebase
cd etebase || exit
pipenv install
pipenv install gunicorn
# server config
echo "$PASSWORD" > secret.txt
pipenv run ./manage.py migrate
echo "Create super user"
pipenv run ./manage.py createsuperuser
tee etebase-server.ini > /dev/null << EOF
[global]
secret_file = secret.txt
debug = false
[allowed_hosts]
allowed_host1 = 127.0.0.1
allowed_host2 = $DOMAIN
[database]
engine = django.db.backends.sqlite3
name = db.sqlite3
EOF
# uwsgi file
tee etebase.ini > /dev/null << EOF
[uwsgi]
socket = $REPO/etebase.sock
chown-socket = $USER:$GROUP
chmod-socket = 660
vacuum = true
plugins = python3
uid = etebase
chdir = $REPO
module = etebase_server.wsgi
master = true
EOF
# test
# test 1 > pipenv run ./manage.py runserver 0.0.0.0:8000
# test 2 > pipenv run gunicorn -b 0.0.0.0 etebase_server.wsgi
# install cronjob
tee run.sh > /dev/null << EOF
#! /bin/sh
cd "$(readlink -f "$0" | xargs dirname)"
pipenv run gunicorn -b 127.0.0.1 etebase_server.wsgi
EOF
chmod +x run.sh
(crontab -l 2>/dev/null; echo "@reboot $REPO/run.sh") | crontab -
Similar to #40 in concept (just for alpine instead of Debian). I wonder if this belongs as an example or rather in the wiki. I think maybe in the wiki, not sure though.
I also thought that this is more suitable to be put in the wiki. Btw, I encounter this weird issue when trying to connect to the instance. It works fine on the previous version though. I will update the script once I resolve this issue.
400 Found wrong host name. Got: "etesync.domain.com" expected: "127.0.0.1:8000"
I have tried adding more allowed_host or add proxy_set_header as per #66 but nothing works.
Let's continue this discussion in #66, though it indeed seems to be the same issue. I guess this should be better documented.
Essentially you want to do two things:
Set ALLOWED_HOSTS to etesync.domain.com.
And proxy_set_header Host etesync.domain.com;
Let's continue this discussion in #66, though it indeed seems to be the same issue. I guess this should be better documented. Essentially you want to do two things: Set ALLOWED_HOSTS to
etesync.domain.com. Andproxy_set_header Host etesync.domain.com;
Thanks, it works! I have updated the script/
Great. :) Will update the readme in a moment.