User Tools

Site Tools


servers:nginx:gauth

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
servers:nginx:gauth [2017/09/15 19:55] Sean Rhoneservers:nginx:gauth [2017/09/15 20:03] Sean Rhone
Line 1: Line 1:
 +https://github.com/gbraad/gauth
  
 +
 +====== Information ======
 +
 +  * GAuth ((https://github.com/gbraad/gauth))
 +  * https://2fa.realmofespionage.xyz ((TODO: Add this))
 +
 +===== Prerequisites =====
 +
 +  * [[distros:ubuntu_server | Ubuntu Server]]
 +  * [[servers:nginx_php_php-fpm | nginx]]
 +  * [[servers:nginx:lets_encrypt | Let's Encrypt]]
 +
 +====== Download Source ======
 +
 +****
 +
 +  sudo git clone -b 'master' 'https://github.com/gbraad/gauth.git' '/var/www/2fa' --depth 1 && sudo chown -R 'nginx':'nginx' '/var/www/2fa' && sync
 +
 +====== nginx Configuration ======
 +
 +===== Server Block ======
 +
 +  sudo -e '/etc/nginx/conf.d/2fa.conf' && sudo systemctl reload 'nginx'
 +
 +<code>
 +server {
 +    listen '443' 'ssl' 'http2';
 +    server_name 'test.realmofespionage.xyz';
 +    root '/var/www/2fa';
 +    index 'index.html';
 +
 +    include '/etc/nginx/default.d/restrictions.conf';
 +
 +#    access_log /var/log/nginx/2fa-access.log;
 +#    error_log /var/log/nginx/2fa-error.log;
 +
 +    location / {
 +        allow 192.168.1.0/24;
 +        deny all;
 +    }
 +}</code>
 +
 +====== Services ======
 +
 +===== Updater =====
 +
 +==== Service ====
 +
 +  sudo -e '/etc/systemd/system/2fa-up.service'
 +
 +  [Service]
 +  User=nginx
 +  Group=nginx
 +  Type=oneshot
 +  ExecStart='/usr/bin/git' -C '/var/www/2fa' pull origin 'master'
 +  ExecStartPost='/bin/sync'
 +
 +==== Timer ====
 +
 +  sudo -e '/etc/systemd/system/2fa-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable '2fa-up.timer' --now && sudo systemctl start '2fa-up' && sudo systemctl status '2fa-up' -l
 +
 +  [Unit]
 +  Description=GAuth Git Updater
 +  After=network-online.target
 +  Wants=network-online.target
 +  
 +  [Timer]
 +  OnCalendar=*-*-* 01:00:00
 +  Persistent=true
 +  
 +  [Install]
 +  WantedBy=timers.target
 +
 +===== Backup =====
 +
 +  * This backs up an archive to the local disk and [[distros:ubuntu_server#nas_backups | to a NAS]]
 +
 +==== Service ====
 +
 +  mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/2fa-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/2fa-fb.service'
 +
 +  [Service]
 +  Type=oneshot
 +  WorkingDirectory=/var/www/2fa
 +  ExecStart='/bin/bash' -c '"/bin/tar" -cvzf "/home/CHANGEME/backups/gauth-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "data/pages" "data/meta" "data/media" "data/media_meta" "data/attic" "data/media_attic" "conf"'
 +  ExecStartPost='/bin/sync'
 +
 +==== Timer ====
 +
 +  sudo -e '/etc/systemd/system/wiki-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'wiki-fb.timer' --now && sudo systemctl start 'wiki-fb' && sudo systemctl status 'wiki-fb' -l
 +
 +  [Unit]
 +  Description=DokuWiki Files Backup
 +  
 +  [Timer]
 +  OnCalendar=*-*-* 01:05:00
 +  Persistent=true
 +  
 +  [Install]
 +  WantedBy=timers.target
 +
 +====== Backup ======
 +
 +  * Create backup archive on server and transfer to client computer
 +
 +===== Server =====
 +
 +==== Archive Folders ====
 +
 +****
 +
 +  cd '/var/www/wiki' && sudo tar -cvzf ~/'dokuwiki-files-manual-'$(date +%Y-%m-%d)'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && cd ~ && sync
 +
 +===== Client =====
 +
 +==== Transfer Archive to Client ====
 +
 +****
 +
 +  scp espionage724@192.168.1.153:~/'dokuwiki-files-'*'.tar.gz' ~/'Downloads' && sync
 +
 +====== Restore ======
 +
 +===== Client =====
 +
 +==== Transfer Archive to Server ====
 +
 +****
 +
 +  scp ~/'Downloads/dokuwiki-files-'*'.tar.gz' espionage724@192.168.1.153:~
 +
 +==== Remove Archive ====
 +
 +****
 +
 +  rm ~/'Downloads/dokuwiki-files-'*'.tar.gz' && sync
 +
 +===== Server =====
 +
 +==== Stop nginx ====
 +
 +****
 +
 +  sudo systemctl stop 'nginx'
 +
 +==== Remove Previous Folders ====
 +
 +****
 +
 +  sudo rm -Rf '/var/www/wiki/data/pages' '/var/www/wiki/data/meta' '/var/www/wiki/data/media' '/var/www/wiki/data/media_meta' '/var/www/wiki/data/attic' '/var/www/wiki/data/media_attic' '/var/www/wiki/conf'
 +
 +==== Restore Folders ====
 +
 +****
 +
 +  cd '/var/www/wiki' && sudo tar -xvzf ~/'gauth-files-'*'.tar.gz' 'data/pages' 'data/meta' 'data/media' 'data/media_meta' 'data/attic' 'data/media_attic' 'conf' && sudo chown -R 'nginx':'nginx' '/var/www/wiki' && cd ~ && sync
 +
 +==== Start nginx ====
 +
 +****
 +
 +  sudo systemctl start 'nginx'
 +
 +==== Remove Archive ====
 +
 +  * Verify that GAuth works before running
 +
 +  rm -R ~/'gauth-files-'*'.tar.gz' && sync