socialnerds/accounts
socialnerds
/
accounts
Archived
1
0
Fork 0
This repository has been archived on 2022-04-16. You can view files and clone it, but cannot push or open issues or pull requests.
accounts/README.md

117 lines
3.0 KiB
Markdown

# accounts
A self-service web application for [Mail-in-a-box](https://mailinabox.email/).
We run it here: https://accounts.socialnerds.org
It is a very simple web application for users to manage their Mail-in-a-box account. I wrote this as a python/bottlepy learning project and to service users at my own Mail-in-a-box. There might be more features in the future.
**Features**
* Login with Mail-in-a-box account
* Change password
* Manage email aliases
* Delete own account (softdelete)
## Installation
You need python installed (v3 or v2). Needed modules: requests, configparser, bottle(or just download bottlepy like below)
```
git clone git@socialg.it:socialnerds.org/accounts.git
cd accounts
wget https://raw.githubusercontent.com/bottlepy/bottle/0.12.10/bottle.py
```
Configure your app by renaming `app.conf.sample` into `app.conf` and edit accordingly.
Start it with:
```
python3 app.py
```
You should be able to see the login page at http://localhost:8000.
## Deployment
If you want to host this somewhere more prominent following links could help: (someday i might write up some real documentation)
* https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
* http://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd
* http://stackoverflow.com/questions/30763586/starting-bottle-web-server-through-systemd
This is what i did on an Ubuntu 16.04 server with apache2:
I enabled following Apache modules (for future instance balancing plans):
```
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_ajp
a2enmod rewrite
a2enmod deflate
a2enmod headers
a2enmod proxy_balancer
a2enmod proxy_connect
a2enmod proxy_html
a2enmod xml2enc
```
Apache vhost config:
```
<VirtualHost *:80>
DocumentRoot /var/www/accounts/static
ServerAdmin admin@domain.tld
ServerName accounts.domain.tld
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/accounts_access.log combined
Redirect permanent / https://accounts.domain.tld/
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin admin@domain.tld
ServerName accounts.domain.tld
DocumentRoot /var/www/accounts/static
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
ErrorLog ${APACHE_LOG_DIR}/accounts_ssl_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/accounts_ssl_access.log combined
SSLEngine on
SSLCertificateFile /path/to/fullchain.pem
SSLCertificateKeyFile /path/to/key.pem
ProxyPreserveHost On
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
</VirtualHost>
</IfModule>
```
Unit file for systemd. `/lib/systemd/system/accounts.service`
Enable service with `sudo systemctl enable accounts.service`
```
[Unit]
Description=Accounts App
After=multi-user.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/var/www/accounts
ExecStart=/usr/bin/python3 /var/www/accounts/app.py
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target
```