ports:web:diaspora

Ceci est une ancienne révision du document !


Papoter sur Diaspora

Diaspora est un service de réseau social décentralisé.

Cet article va vous décrire l'installation d'un serveur Diaspora, dans une jail.

Vous devez vous préparer à fournir les ports suivants:

  1. un serveur web, ici nginx;
  2. un mécanisme pour fournir des clefs pour https, ici py-certbot-nginx;
  3. Ainsi qu'un serveur de base de données PostgreSQL, installée dans une jail en 192.168.0.10, pour cet exemple.

Préparez une jail nommée diaspora, dans le répertoire /jails/diaspora avec les paramètres suivants:

/etc/jail.conf
matrix {
	ip4.addr = "lo1|192.168.0.13";          # IP address of the jail
        mount.devfs;  				# /dev/random pour SSL
	path ="/jails/diaspora";                  # Path to the jail
	exec.start = "/bin/sh /etc/rc";         # Start command
	exec.stop = "/bin/sh /etc/rc.shutdown"; # Stop command
	depend=pg; # depend on postgresql jail
}

Adaptez la configuration de la jail diapora:

matrix/etc/rc.conf.local
hostname="diaspora.lapinbilly.eu"
Un serveur diaspora va vouloir envoyer des mails. Un hostname(1) en FQDN est obligatoire.

Préparez votre base de donnée pour Diaspora. Dans cet exemple, le serveur est confiné dans une jail nommée pg.

Créer un utilisateur, diaspora, qui a le droits de créer des bases:

root@pg:/ # su - postgres
$ createuser -P -d diaspora
Enter password for new role: 
Enter it again: 

Restreindre l'accès au serveur de base de données à cet utilisateur, pour les demandes venant de la jail diaspora en 192.168.0.13.

/jails/pg/var/db/postgres/data11/pg_hba.conf
host    all				diaspora        192.168.0.13/32            password

Créez une entrée DNS, ici diaspora.lapinbilly.eu, pour votre serveur et rediriger le tout vers la jail diaspora.

Obtenez un certificat SSL.

root@popeye:/jails# certbot certonly --nginx -d diaspora.lapinbilly.eu

Rediriger les requêtes vers votre jail, pour cela, on va définir un fichier dédié pour nginx.

/usr/local/etc/nginx/diaspora.conf
server {
    root  /jails/diaspora/usr/home/diaspora/diaspora/public/;
    # Configure maximum picture size
    # Note that Diaspora has a client side check set at 4M
    client_max_body_size 5M;
    client_body_buffer_size 256K;
    ssl_certificate /usr/local/etc/letsencrypt/live/diaspora.lapinbilly.eu/fullchain.pem;
    ssl_certificate_key /usr/local/etc/letsencrypt/live/diaspora.lapinbilly.eu/privkey.pem;
 
    # Proxy if requested file not found
    try_files $uri @diaspora;
 
    location /assets/ {
      expires max;
      add_header Cache-Control public;
    }
 
    # Camo support
    #location /camo/ {
    #  proxy_redirect off;
    #  proxy_pass http://camo/;
    #  break;
    #}
 
    location @diaspora {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://diaspora_server;
    }
  }
  upstream diaspora_server {
    server unix:/jails/diaspora/usr/home/diaspora/diaspora/tmp/diaspora.sock;
  }

Et l'utiliser dans nos serveurs nginx

/usr/local/etc/nginx/nginx.conf
   server {
            listen 443 ssl http2 ;
            listen [::]:443 ssl http2 ;
            server_name diaspora.lapinbilly.eu;
            include diaspora.conf;
    }

Installez les ports suivants dans la jail diaspora:

root@popeye:# pkg -j diaspora graphics/ImageMagick7-nox11 databases/redis lang/ruby26 sysutils/rubygem-bundler www/node databases/rubygem-pg devel/git textproc/libsass devel/gmake
root@popeye:# sysrc -j  diaspora redis_enable="YES"

Construisez le serveur:

root@popeye:# jail -c diaspora
root@popeye:# service -j diaspora service redis start
root@popeye:# jexec disapora
root@diaspora:# gem install certified
root@diaspora:# certified-update
root@diaspora:# gem install bundler
root@diaspora:# gem install rake -v '12.3.3'

Ajoutez un utilisateur diaspora:

root@diaspora:# pw useradd diaspora -c "Diaspora user"
root@diaspora:# echo "setenv RAILS_ENV production" >> ~diaspora/.cshrc
root@diaspora:# echo "setenv DB postgresql" >> ~diaspora/.cshrc
root@diaspora:# su - diaspora
diaspora@diaspora:~ % git clone -b master https://github.com/diaspora/diaspora.git
diaspora@diaspora:~ % cd diaspora/
diaspora@diaspora:~/diaspora % cp config/diaspora.yml.example config/diaspora.yml
diaspora@diaspora:~/diaspora % cp config/database.yml.example config/database.yml
diaspora@diaspora:~/diaspora % script/configure_bundler
diaspora@diaspora:~/diaspora % bundle install --without test development --path vendor/bundle
diaspora@diaspora:~/diaspora % bundle update --bundler
diaspora@diaspora:~/diaspora % bundle exec rake db:create db:migrate
diaspora@diaspora:~/diaspora % bin/rake assets:precompile

Dirigez la connexion vers votre base de données

config/database.yml
--- config/database.yml 2020-05-02 21:34:04.844275000 +0200
+++ config/database.yml.example 2020-05-02 21:28:46.158354000 +0200
@@ -1,9 +1,9 @@
 postgresql: &postgresql
   adapter: postgresql
-  host: "192.168.0.10"
+  host: "localhost"
   port: 5432
-  username: "diaspora"
-  password: "pwd"
+  username: "postgres"
+  password: ""
   encoding: unicode
 
 mysql: &mysql

Donnez le bon chemin vers les certificats:

config/diaspora.yml
--- config/diaspora.yml.example 2020-05-02 21:28:46.158783000 +0200
+++ config/diaspora.yml 2020-05-04 00:00:32.367677000 +0200
@@ -36,7 +36,7 @@
     ## However changing http to https is okay and has no consequences.
     ## If you do change the URL, you will have to start again as the URL
     ## will be hardcoded into the database.
-    #url: "https://example.org/"
+    url: "https://diaspora.lapinbilly.eu/"
 
     ## Set the bundle of certificate authorities (CA) certificates.
     ## This is specific to your operating system.
@@ -44,7 +44,7 @@
     ## For Debian, Ubuntu, Archlinux, Gentoo (package ca-certificates):
     #certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'
     ## For CentOS, Fedora:
-    #certificate_authorities: '/etc/pki/tls/certs/ca-bundle.crt'
+    certificate_authorities: '/usr/local/share/certs/ca-root-nss.crt'
 
     ## URL for a remote Redis (default=localhost).
     ## Don't forget to restrict IP access if you uncomment these!
@@ -175,7 +175,7 @@
     ## Where the appserver should listen to (default=unix:tmp/diaspora.sock)
     #listen: 'unix:tmp/diaspora.sock'
     #listen: 'unix:/run/diaspora/diaspora.sock'
-    #listen: '127.0.0.1:3000'
+    #listen: '192.168.0.15:3000'
 
     ## Set the path for the PID file of the unicorn master process (default=tmp/pids/web.pid)
     #pid: 'tmp/pids/web.pid'
@@ -609,14 +609,14 @@
   mail: ## Section
 
     ## First you need to enable it.
-    #enable: true
+    enable: true
 
     ## Sender address used in mail sent by Diaspora.
-    #sender_address: 'no-reply@example.org'
+    sender_address: 'no-reply@lapinbilly.eu'
 
     ## This selects which mailer should be used. Use 'smtp' for a smtp
     ## connection or 'sendmail' to use the sendmail binary.
-    #method: 'smtp'
+    method: 'sendmail'
 
     ## Ignore if method isn't 'smtp'.
     smtp: ## Section
@@ -653,7 +653,7 @@
     sendmail: ## Section
 
       ## The path to the sendmail binary (default='/usr/sbin/sendmail')
-      #location: '/usr/sbin/sendmail'
+      location: '/usr/sbin/sendmail'
 
       ## Use exim and sendmail (default=false)
       #exim_fix: false
@@ -665,10 +665,10 @@
     ## This doesn't make the user an admin but is used when a generic
     ## admin contact is needed, much like the postmaster role in mail
     ## systems. Set only the username, NOT the full ID.
-    #account: "podmaster"
+    account: "podmaster"
 
     ## E-mail address to contact the administrator.
-    #podmin_email: 'podmin@example.org'
+    podmin_email: 'david@lapinbilly.eu'
 
   ## Settings related to relays
   relay: ## Section

Adaptez le serveur à la jail et au serveur de base de données, c'est à dire permettre au serveur diaspora d'écouter les requêtes venant de l'hôte et lui indiquer le chemin vers le serveur PostgreSQL.

Lancez simplement:

diaspora@diaspora:~/diaspora % ./script/server

Redémarrez votre serveur web avec la nouvelle configuration:

root@popeye:# service nginx restart
  • ports/web/diaspora.1588543538.txt.gz
  • Dernière modification : 2020/05/03 22:05
  • de david