Ltsu

Installation des paquets nécessaires

apt-get install build-essential libssl-dev zlib1g-dev curl libpng-dev

Installation des dépendances PERL

cpan Carton

On récupère ltsu et on l’installe

  • ici on utilise sqlite
cd /opt
git clone https://framagit.org/luc/lstu.git
carton install --deployment --without=test --without=postgresql --without=mysql --without=cache --without=ldap

Configuration de ltsu

cd /opt/ltsu
cp lstu.conf.template lstu.conf
  • /opt/ltsu/lstu.conf

Pour ma part, j’ai modifié ou décommenté :

  • listen => [‘http://IP_PRIV:8080’],
  • proxy => 1,
  • contact => ‘MAIL ADMIN’,
  • secret => [‘RANDOM’],
  • hashed_adminpwd => ‘HASH_PASSWORD’,
  • dbtype => ‘sqlite’,
  • db_path => ‘lstu.db’,
  • csp => “default-src ‘none’; script-src ‘self’; style-src ‘self’; img-src ‘self’ data:; font-src ‘self’; form-action ‘self’; base-uri ‘self’”,

Unité systemD

[Unit]
Description=Shortened URLs service
Documentation=https://framagit.org/fiat-tux/hat-softwares/lstu
Requires=network.target
After=network.target

[Service]
Type=forking
User=www-data
RemainAfterExit=yes
WorkingDirectory=/opt/lstu/
PIDFile=/opt/lstu/script/hypnotoad.pid
ExecStart=/usr/local/bin/carton exec hypnotoad script/lstu
ExecStop=/usr/local/bin/carton exec hypnotoad -s script/lstu
ExecReload=/usr/local/bin/carton exec hypnotoad script/lstu

[Install]
WantedBy=multi-user.target

On applique les droits

chown -R www-data /opt/lstu

On démarre lstu

systemctl daemon-reload
systemctl enable lstu.service
systemctl start lstu.service

le vhost pour le reverse proxy

server {
    listen      80;
    server_name DOMAIN;
    return 301  https://DOMAIN$request_uri;
}

server {
    listen      443 ssl http2;
    server_name DOMAIN;

    # Let's Encrypt:
    ssl_certificate     /etc/letsencrypt/live/DOMAIN/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;

    # Add common Conf:
    include /etc/nginx/RVPRX_common.conf;

    # LOGS
    gzip on;
    access_log /var/log/nginx/DOMAIN_access.log;
    error_log  /var/log/nginx/DOMAIN_error.log;

    location / { 
        proxy_pass http://IP_PRIV:8080;
    }
}