mirror of
https://github.com/YunoHost/dynette.git
synced 2024-09-03 20:06:17 +02:00
Conf handling improvements, backported from dynette_ynh
This commit is contained in:
parent
25af17b9b3
commit
963faf742e
4 changed files with 37 additions and 95 deletions
91
README.md
91
README.md
|
@ -10,20 +10,12 @@ You can use the dynette_ynh package for YunoHost
|
|||
https://github.com/YunoHost-Apps/dynette_ynh
|
||||
|
||||
|
||||
Manual setup
|
||||
-------------------------------
|
||||
|
||||
```
|
||||
git clone https://github.com/YunoHost/dynette
|
||||
```
|
||||
|
||||
|
||||
Web subscribe server deployment
|
||||
-------------------------------
|
||||
|
||||
Install required stuff
|
||||
```
|
||||
$ apt-get install postgresql postgresql-server-dev-9.4 ruby thin libpq-dev bundler apache2 bind9 python
|
||||
$ apt install postgresql postgresql-server-dev-all ruby thin libpq-dev bundler nginx bind9 python3
|
||||
```
|
||||
|
||||
Prepare user dynette
|
||||
|
@ -64,56 +56,7 @@ thin config -C /etc/thin2.1/dynette.yml -c /home/dynette/dynette/ --servers 3 -p
|
|||
service thin restart
|
||||
```
|
||||
|
||||
|
||||
Apache configuration
|
||||
--------------------
|
||||
|
||||
```
|
||||
vim /etc/apache2/sites-available/dynette
|
||||
```
|
||||
|
||||
Paste & change server name in below configuration:
|
||||
```
|
||||
<VirtualHost *:80>
|
||||
ServerName dyndns.yunohost.org
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
<Proxy balancer://thinservers>
|
||||
BalancerMember http://127.0.0.1:5000
|
||||
BalancerMember http://127.0.0.1:5001
|
||||
BalancerMember http://127.0.0.1:5002
|
||||
</Proxy>
|
||||
|
||||
# Redirect all non-static requests to thin
|
||||
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^/(.*)$ balancer://thinservers%{REQUEST_URI} [P,QSA,L]
|
||||
|
||||
ProxyPass / balancer://thinservers/
|
||||
ProxyPassReverse / balancer://thinservers/
|
||||
ProxyPreserveHost on
|
||||
|
||||
<Proxy *>
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</Proxy>
|
||||
|
||||
# Custom log file locations
|
||||
ErrorLog /var/log/apache2/dynette-error.log
|
||||
CustomLog /var/log/apache2/dynette-access.log combined
|
||||
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
Enable apache2 sites & modules:
|
||||
```
|
||||
a2enmod proxy
|
||||
a2enmod rewrite
|
||||
a2ensite dynette
|
||||
service apache2 restart
|
||||
```
|
||||
|
||||
Alternative nginx configuration
|
||||
nginx configuration
|
||||
--------------------
|
||||
Alternatively you can use nginx
|
||||
|
||||
|
@ -145,27 +88,14 @@ server {
|
|||
proxy_redirect off;
|
||||
proxy_pass http://dynette;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Cron job configuration
|
||||
----------------------
|
||||
Configure
|
||||
---------
|
||||
|
||||
Edit dynette.cron.py and change settings:
|
||||
```
|
||||
# If you want to simply do test in local, use "http://127.0.0.1:5000/"
|
||||
subs_urls = ['https://dyndns.yunohost.org']
|
||||
ns0 = 'ns0.yunohost.org'
|
||||
ns1 = 'ns1.yunohost.org'
|
||||
```
|
||||
`cp config.file.j2 config.file` and fill all the info
|
||||
|
||||
Create and edit master.key file is Dynette directory
|
||||
```
|
||||
echo "MyMasterKey" > master.key
|
||||
```
|
||||
|
||||
Create dynette log file
|
||||
```
|
||||
touch /var/log/dynette.log
|
||||
```
|
||||
|
@ -174,19 +104,12 @@ Enable cronjob for dynette (crontab -e)
|
|||
```
|
||||
* * * * * /path/to/dynette/dynette.cron.py >> /var/log/dynette.log 2>&1
|
||||
```
|
||||
|
||||
Test it's working
|
||||
-----------------
|
||||
|
||||
`wget -q -O - http://127.0.0.1:5000/test/someDomain.nohost.me`
|
||||
|
||||
Adding a new subdomain
|
||||
----------------------
|
||||
|
||||
- Add the domain in `DOMAINS` in dynette.rb
|
||||
- Restart dynette (and/or thin ?)
|
||||
- Check that https://dynette.tld/domains actually shows the new domain
|
||||
- Test adding a new domain from YunoHost
|
||||
|
||||
Troobleshooting
|
||||
---------------
|
||||
|
||||
|
|
9
config.json.j2
Normal file
9
config.json.j2
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"database_url": "postgres://{{ db_user }}:{{ db_password }}@localhost/{{ db_name }}",
|
||||
"domains" : [ {{ subdomains }} ],
|
||||
"subs_url" : [ https://{{ dynette_domain }} ],
|
||||
"ns0" : {{ ns0 }},
|
||||
"ns1" : {{ ns1 }},
|
||||
"rname" : {{ rname }},
|
||||
"master_key" : {{ master_key }}
|
||||
}
|
|
@ -2,13 +2,19 @@
|
|||
|
||||
### Configuration ###
|
||||
|
||||
import json
|
||||
|
||||
with open('config.json') as config_file:
|
||||
config = json.load(config_file)
|
||||
|
||||
postgresql_dsn = "dbname=dynette user=dynette password=myPassword"
|
||||
conf_file = '/etc/bind/named.conf.local' # Include this filename in '/etc/bind/named.conf'
|
||||
zone_dir = '/var/lib/bind/' # Do not forget the trailing '/'
|
||||
subs_urls = ['https://dyndns.yunohost.org'] # 127.0.0.1 if you install subscribe server locally
|
||||
ns0 = 'ns0.yunohost.org' # Name servers
|
||||
ns1 = 'ns1.yunohost.org'
|
||||
rname = 'hostmaster@yunohost.org' # Responsible person (https://tools.ietf.org/html/rfc1035#section-3.3.13)
|
||||
subs_urls = config_file["subs_urls"] # 127.0.0.1 if you install subscribe server locally
|
||||
ns0 = config_file["ns0"] # Name servers
|
||||
ns1 = config_file["ns1"]
|
||||
rname = config_file["rname"] # Responsible person (https://tools.ietf.org/html/rfc1035#section-3.3.13)
|
||||
master_key = config_file["master_key"]
|
||||
|
||||
allowed_operations = {
|
||||
'.' : ['A', 'AAAA', 'TXT', 'MX', 'CAA'],
|
||||
|
@ -28,14 +34,10 @@ allowed_operations = {
|
|||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import psycopg2
|
||||
from urllib import urlopen
|
||||
|
||||
|
||||
# Get master key
|
||||
master_key_path = os.path.join(os.path.dirname(__file__), 'master.key')
|
||||
master_key = open(master_key_path).read().rstrip()
|
||||
|
||||
# Bind configuration
|
||||
lines = ['// Generated by Dynette CRON']
|
||||
|
|
14
dynette.rb
14
dynette.rb
|
@ -11,10 +11,18 @@ require 'bcrypt'
|
|||
### Configuration ###
|
||||
######################
|
||||
|
||||
DataMapper.setup(:default, ENV['DATABASE_URL'] || "postgres://dynette:myPassword@localhost/dynette")
|
||||
DOMAINS = ["nohost.me", "noho.st", "ynh.fr"]
|
||||
ALLOWED_IP = ["127.0.0.1"]
|
||||
# Read configuration file
|
||||
begin
|
||||
config_file = File.read('config.json')
|
||||
config = JSON.parse(config_file)
|
||||
rescue => err
|
||||
puts "Exception: #{err}"
|
||||
err
|
||||
end
|
||||
|
||||
DataMapper.setup(:default, ENV['DATABASE_URL'] || config['database_url'])
|
||||
DOMAINS = config['domains']
|
||||
ALLOWED_IP = ["127.0.0.1"]
|
||||
|
||||
###############
|
||||
### Classes ###
|
||||
|
|
Loading…
Add table
Reference in a new issue