Some changes

This commit is contained in:
el Mau 2023-01-03 22:25:40 -06:00
parent ca4cd71110
commit dc22f6d0af
21 changed files with 3497 additions and 368 deletions

View File

@ -0,0 +1,25 @@
## Nuevo Año
### Si, hice trampa...
Esta entrada la tenía en borrador desde el año pasado, y ahora que ya estamos por terminar el segundo mes del año la termino... pero... no es relevante...
No soy de los que se ponen a reflexionar a fin de año, de hecho, en ninguna parte del año :), por reflexionar entiendo ese ejercicio estéril de pensar en lo que se hizo y en lo que se piensa hacer, sin hacerlo... por eso es estéril.
¿Reflexionar?, claro, dado el potencial de la mente, para bien y para mal nada más hay que ver en donde estamos. No soy de los que creen que usamos solo una ínfima parte, si no por el contrario, en general usamos una buena parte de el, ¿en que lo usamos?... ese es otro tema.
Entonces, se trata de usar nuestra mente. Hace poco vi la página de una chica en sus veintes, entre todo lo que sabía, sabía más de cinco idiomas, entre ellos el griego. Una simple nota a pie decía: "uso mi mente".
Si hacemos a un lado esas "rutinas y hábitos" que se han incorporado en nuestros procesos de pensamiento, por lo cual no demandan "tanto esfuerzo" (así dicen que se logra la excelencia en cualquier área, hacerlo un hábito), el poner a prueba nuestra mente podría ser nuestro "imperativo categórico".
Si algo te gusta pero te demanda esfuerzo o te parece difícil, ese puede ser tu reto. Me gustan mucho los idiomas, pero me cuestan mucho trabajo, así que es un reto diario para mi en esforzarme en entender y aprender, aunque parezca por momentos que no avanzo.
Por el contrario, si una actividad te "aburre", es síntoma claro de que hay que cambiar de reto, afortunadamente sobran retos, alguno debe de poner a prueba tu mente.
Eso si, no la dejes morir de inanición, no hay nada más triste que ver dormido o desperdiciado todo ese potencial.
Un abrazo
=> gemini://elmau.net/blog • Regresar al índice.

View File

@ -0,0 +1,12 @@
## Principio de Pareto
### no todos tienen que hacer de todo
Un abrazo
=> gemini://elmau.net/blog • Regresar al índice.

View File

@ -5,6 +5,8 @@ Las únicas que me leen. :)
=> gemini://elmau.net • Regresar al inicio
=> gemini://elmau.net/blog/2022_02_01_pareto.gmi • [2022-01-01] Principio de Pareto
=> gemini://elmau.net/blog/2022_01_01_nuevo_año.gmi • [2022-01-01] Nuevo año
=> gemini://elmau.net/blog/vitae.gmi • [2021-06-19] Vitae - una película especial
=> gemini://elmau.net/blog/gemini-no-sirve-para-nada.gmi • [2021-06-13] Gemini no sirve para nada
=> gemini://elmau.net/blog/soberania-tecnologica2-intro.gmi • [2021-05-31] Soberanía tecnológica 2

View File

@ -2,6 +2,10 @@
## Porqué la memoria ya no es la misma
=> gemini://elmau.net/notes/seafile.gmi • [SeaFile]
=> gemini://elmau.net/notes/mastodon.gmi • [Mastodon]
=> gemini://elmau.net/notes/duniter.gmi • [Duniter - Servidor G1]
=> gemini://elmau.net/notes/jetforce.gmi • [JetForce - Servidor Gemini]
=> gemini://elmau.net/notes/nginx.gmi • [Nginx - Servidor web]
=> gemini://elmau.net/notes/ffmpeg.gmi • [ffmpeg]
@ -11,8 +15,8 @@
=> gemini://elmau.net/notes/vim.gmi • [Vim]
=> gemini://elmau.net/notes/postgres.gmi • [Postgres]
=> gemini://elmau.net/notes/mailserver.gmi • [Mail Server]
=> gemini://elmau.net/notes/seafile.gmi • [SeaFile]
=> gemini://elmau.net/notes/seafile-client.gmi • [Cliente SeaFile]
=> gemini://elmau.net/notes/matrix.gmi • [Matrix - Servidor]

View File

@ -16,9 +16,8 @@ Puedes conversar conmigo en:
* Mastodon: @mstdn.mx@elmau
* Matrix: @elmau:matrix.cuates.net
* Telegram: @mauriciobaeza
* XMPP: gemini_es@salas.suchat.org
* Correo eletrónico: hola1@correolibre.net
* XMPP: elmau@suchat.org
* Correo eletrónico: publico@cuates.net
=> gemini://elmau.net Regresar el inicio

View File

@ -2,21 +2,17 @@
Si no esta tu sitio, por favor, envíamelo para agregarlo.
Ordenadas en orden alfabético.
Sin ningún orden.
=> gemini://bucareli.online/gemlog/ • de Bucareli
=> gemini://gemini.solobsd.org • The Dark Muon
=> gemini://c3po.aljadra.xyz • de c3po
=> gemini://capsula.pabs.xyz/ • de Pabs
=> gemini://caracolito.mooo.com/ • de caracolito
=> gemini://caracolito.mooo.com/~maleza/ • Mateada pachapunk
=> gemini://caracolito.mooo.com/~sejo/ • de ISO simpleza
=> gemini://cosmic.voyage/ • Bot en deriva
=> gemini://enteka.xyz/ • de Enteka
=> gemini://gem.juancastro.xyz/indice.gmi • de Juan Castro
=> gemini://gemini.bmesh.org/ • BMesh
=> gemini://gemini.elbinario.net/ • El Binario
=> gemini://gemlog.blue/users/miya/ • de Miya
=> gemini://gemlog.gamifi.cat/ • de Gamifi [Catalán]
=> gemini://michan.noho.st/ • de Roboron
=> gemini://monmac.flounder.online/ • de Manuel Monroy Correa
=> gemini://moribundo.flounder.online/ • de Moribundo Insurgente
@ -24,11 +20,15 @@ Ordenadas en orden alfabético.
=> gemini://sl1200.flounder.online/ • de sl1200
=> gemini://soviet.circumlunar.space/sejo/ • La Cabañita
=> gemini://srlobo.gorritodeplata.xyz • del Sr. Lobo
=> gemini://gemlog.blue/users/monika/ • de Monika
=> gemini://aperalesf.flounder.online/ • Adrian Perales
=> gemini://gemlog.blue/users/alien/ • Alien
=> gemini://lind.archipielago.uno • La La Lind
=> gemini://compudanzas.net/inicio.gmi • Compudanzas
=> gemini://gemini.elbinario.net/ • El Binario
Otros idiomas
=> gemini://gemlog.gamifi.cat/ • de Gamifi [Catalán]
=> gemini://gemini.circumlunar.space/ • Proyecto Gemini (Inglés)
=> gemini://translate.metalune.xyz/ • Simply Translate

View File

@ -1,82 +0,0 @@
## Alma Linux 8.4
Agregar un usuario.
```
adduser USER
```
Agregar un usuario a un grupo.
```
gpasswd -a USER GRUPO
```
Establecer el uso horario
```Establecer el uso horario
sudo timedatectl set-timezone America/Mexico_City
```
Mantener actualizado el servidor
```Mantener actualizado
dnf check-update
dnf update
```
Establecer un mejor prompt
```Establecer un mejor prompt
vim .bashrc
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;1m\]}\n└──> \[\e[0m\]"
source .bashrc
```
Establecer el hostname
```Establecer el hostname
sudo hostnamectl set-hostname elmau.net
sudo vim /etc/hostname
elmau.net
sudo vim /etc/hosts
127.0.0.1 elmau.net localhost
```
Establecer configuración para `ssh`
```Establecer configuración para ssh
sudo vim /etc/ssh/sshd_config
Port 2274
AllowUsers USER
PermitRootLogin no
LoginGraceTime 1m
ClientAliveInterval 600
ClientAliveCountMax 0
MaxAuthTries 3
IgnoreRhosts yes
PermitEmptyPasswords no
PasswordAuthentication no
LogLevel INFO
```
=> gemini://elmau.net/chuletas.gmi Regresar el índice
=> gemini://elmau.net Regresar el inicio

187
source/notes/bookwyrm.gmi Normal file
View File

@ -0,0 +1,187 @@
apt update
apt upgrade -y
do-release-upgrade
localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
vim /etc/environment
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales
hostnamectl set-hostname lectura.social
vim /etc/hosts
127.0.0.1 lectura.social localhost
vim /etc/security/limits.conf
* soft nofile 20480
adduser bookwyrm
gpasswd -a bookwyrm sudo
sudo apt install python3-pip python3-venv python-is-python3
sudo pip3 install --upgrade pip wheel
sudo apt install vim libpq-dev postgresql redis nginx certbot git
sudo vim /etc/postgresql/12/main/pg_hba.conf
local all postgres trust
local all all scram-sha-256
systemctl restart postgresql
CREATE ROLE bookwyrm WITH LOGIN ENCRYPTED PASSWORD 'cxKxDNnuSJ7piMcMyvg2VK9en';
CREATE DATABASE bookwyrm WITH OWNER bookwyrm;
ALTER USER bookwyrm WITH SUPERUSER;
ALTER USER bookwyrm WITH NOSUPERUSER;
sudo mkdir /opt/bookwyrm
sudo chown bookwyrm:bookwyrm /opt/bookwyrm
cd /opt/bookwyrm
git clone https://github.com/bookwyrm-social/bookwyrm.git ./
git config --global --add safe.directory /opt/bookwyrm
git checkout production
cp .env.example .env
python3 -m venv venv
source venv/bin/activate.fish
pip install --upgrade pip wheel
pip install -r requirements.txt
vim .env
python manage.py migrate
python manage.py initdb
python manage.py collectstatic --no-input
python manage.py admin_code
9dac9b40-c47e-4e56-a00f-0917979e3fd1
sudo systemctl stop nginx
sudo certbot register --agree-tos -m CORREO
sudo certbot certonly --standalone --preferred-challenges http-01 -d lectura.social
/etc/letsencrypt/live/lectura.social/fullchain.pem
/etc/letsencrypt/live/lectura.social/privkey.pem
openssl dhparam -dsaparam -out /etc/letsencrypt/ssl-dhparams.pem 4096
Crear el archivo "options-ssl-nginx.conf"
```
vim /etc/letsencrypt/options-ssl-nginx.conf
```
Con el siguiente contenido:
```
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
```
Crear el archivo "certbot.conf"
```
vim /etc/letsencrypt/certbot.conf
```
Con el siguiente contenido. Asegurate de reemplazar "social.elmau.net" por tu dominio.
```
ssl_certificate /etc/letsencrypt/live/social.elmau.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/social.elmau.net/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
```
sudo rm /etc/nginx/sites-enabled/default
Reemplazar el contenido del archivo "nginx.conf"
```
vim /etc/nginx/nginx.conf
```
Por:
```
user www-data;
worker_processes auto;
worker_rlimit_nofile 20480;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 5120;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
keepalive_timeout 60;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
}
```
sudo cp nginx/production /etc/nginx/sites-available/lectura.social.conf
sudo vim /etc/nginx/sites-available/lectura.social.conf

View File

@ -0,0 +1,46 @@
apt install build-essential unzip
apt install openjdk-11-jre
java -version
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.17-stable.tar.gz
tar -xvf libsodium-1.0.17-stable.tar.gz
cd libsodium-stable/
./configure
make
make check
make install
cd /opt
wget https://github.com/duniter/cesium-plus-pod/releases/download/cesium-plus-pod-1.9.1/cesium-plus-pod-1.9.1-standalone.zip
unzip cesium-plus-pod-1.9.1-standalone.zip
cd cesium-plus-pod-1.9.1/
vim config/elasticsearch.yml
```
```
g1.data.presles.fr
duniter.p2p.includes.endpoints: [
"ES_CORE_API g1.data.e-is.pro 443",
"ES_USER_API g1.data.e-is.pro 443",
"ES_SUBSCRIPTION_API g1.data.e-is.pro 443"
]

575
source/notes/duniter.gmi Normal file
View File

@ -0,0 +1,575 @@
# Instalar servidor Duniter en Ubuntu Server 22.04
Duniter es el software de servidor que permite tener un nodo para la Moneda Libre G1
## Requerimientos previos
1] Un VPS con al menos 2 Cores y 3 de RAM, recomendamos 4 Cores y 4 de RAM con una IP pública asignada.
2] Un dominio o subdominio apuntando a la IP pública del VPS.
Para este ejemplo usaremos:
```
fania.g1server.net
```
Que ya apunta a la IP de nuestro VPS
```
host fania.g1server.net
fania.g1server.net has address 202.61.238.152
```
Es mejor que deshabilites el acceso por contraseña en el servidor y accedas solo con certificados.
Creamos el certificado:
```
ssh-keygen -t ed25519
```
Debes de ver:
```
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/mau/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mau/.ssh/id_ed25519
Your public key has been saved in /home/mau/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:TH7DcxneA2yr7qR6sL9/cePDMKPvAE9zKLx0spUk2c0 mau@oficina
The key's randomart image is:
+--[ED25519 256]--+
| |
| o + |
| + o E |
| = + = * |
| S % * o |
| .. % B= o. |
| oo =. O . |
| . .+... + |
| .+++++o . |
+----[SHA256]-----+
```
Y lo copiamos al servidor:
```
ssh-copy-id -i ~/.ssh/id_ed25519.pub -p22 root@202.61.238.152
```
Al conectar ya no solicita la contraseña. Todo el proceso se realiza como "root".
```
ssh -p22 root@202.61.238.152
```
El servidor debe estar al día e instalamos "unzip".
```
apt update
apt upgrade
apt install unzip
```
Establece tu hostname.
```
hostnamectl set-hostname fania.g1server.net
```
Edita el archivo "hosts".
```
vim /etc/hosts
```
El contenido del archivo "hosts" puede variar, tómalo solo como ejemplo:
```
127.0.0.1 localhost
127.0.1.1 fania.g1server.net fania
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
202.61.238.152 fania.g1server.net fania
```
Los locales de tu server establecemos en los que quieras, inglés esta bien en la mayoría de los casos.
```
localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
```
Agrégalos a las variables de entorno.
```
vim /etc/environment
```
Añades al final de acuerdo a tus locales.
```
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
```
Y los reconfiguras.
```
dpkg-reconfigure locales
```
Establecer un mejor prompt, esto es opcional.
```
vim .bashrc
```
Agregas al final
```
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;1m\]}\n└──> \[\e[0m\]"
```
Recargas para ver el cambio
```
source .bashrc
```
Instalamos certbot
```
apt install certbot
```
Y nos registramos, reemplaza EMAIL por un correo válido.
```
certbot register --agree-tos -m EMAIL
```
Solicitamos el certificado para nuestro subdominio
```
certbot certonly --standalone --preferred-challenges http-01 -d fania.g1server.net
```
Asegurate de guardar las rutas completas de los certificados, las usaremos más adelante.
```
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for fania.g1server.net
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/fania.g1server.net/fullchain.pem
Key is saved at: /etc/letsencrypt/live/fania.g1server.net/privkey.pem
This certificate expires on 2022-08-17.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
```
## Descargar, instalar y configurar Duniter
Descargamos
```
wget https://git.duniter.org/nodes/typescript/duniter/-/releases/v1.8.6/downloads/binaries/duniter-server-v1.8.6-linux-x64.deb
```
Instalamos
```
dpkg -i duniter-server-v1.8.6-linux-x64.deb
Selecting previously unselected package duniter.
(Reading database ... 109598 files and directories currently installed.)
Preparing to unpack duniter-server-v1.8.5-linux-x64.deb ...
Unpacking duniter (1.8.6) ...
Setting up duniter (1.8.6) ...
```
Iniciamos el servicio.
```
systemctl start duniter
```
Es necesario usar "sudo" para estos comando, para que se ejecuten con el usuario "duniter".
Te voy mostrando el resultado de los comandos para que vayas verificando que todo va bien.
```
sudo -u duniter duniter config
2022-05-19T22:49:34+02:00 - debug: Plugging file system...
2022-05-19T22:49:34+02:00 - debug: Loading conf...
2022-05-19T22:49:34+02:00 - debug: Configuration saved.
```
Este paso solo es necesario si; quieres usar tus claves de acceso a tu monedero o si eres miembro de la red de confianza con lo cual puedes crear moneda en tu nodo.
```
sudo -u duniter duniter wizard key
```
Configuramos la red. En el parámetro Remote IPv4, es importante seleccionar la IP pública de tu VPS.
```
sudo -u duniter duniter wizard network
2022-05-19T22:52:05+02:00 - debug: Plugging file system...
2022-05-19T22:52:05+02:00 - debug: Loading conf...
2022-05-19T22:52:05+02:00 - debug: Configuration saved.
? IPv4 interface lo 127.0.0.1
? IPv6 interface None
? Port 10901
? Remote IPv4 eth0 202.61.238.152
? Remote port 443
? Does this server has a DNS name? Yes
? DNS name: fania.g1server.net
2022-05-19T22:54:39+02:00 - debug: Configuration saved.
```
Configuramos el protocolo BMAS.
```
sudo -u duniter duniter config --addep "BMAS fania.g1server.net 443"
2022-05-19T22:56:08+02:00 - debug: Plugging file system...
2022-05-19T22:56:08+02:00 - debug: Loading conf...
2022-05-19T22:56:08+02:00 - debug: Configuration saved.
```
Configuramos el protocolo "ws2p".
```
sudo -u duniter duniter config --ws2p-public --ws2p-noupnp --ws2p-port 20901 --ws2p-host 127.0.0.1 --ws2p-remote-port 443 --ws2p-remote-host fania.g1server.net --ws2p-remote-path "/ws2p"
2022-05-19T22:57:04+02:00 - debug: Plugging file system...
2022-05-19T22:57:04+02:00 - debug: Loading conf...
2022-05-19T22:57:04+02:00 - debug: Configuration saved.
```
Detenemos el servicio.
```
systemctl stop duniter
```
Para sincronizar nuestro nodo. "CUIDADO" esto puede llevarse de 1 a 3 horas dependiendo de la velocidad de tu VPS, de tu conexión, de la disponibilidad de los nodos y otros factores de la red.
```
sudo -u duniter duniter sync g1.duniter.org:443
Progress:
Milestones: [||||||||||||||||||||] 100 %
Download: [||||||||||||||||||||] 100 %
Apply: [||||||||||||||||||||] 100 %
Sandbox: [ ] 0 %
Peers: [||||||||||||||||||||] 100 %
Status: Peer AFv1D5xA7FCdHCTA1bqfQ3PWvwEM16Gw67QJ37obGnsv
All done in 5352.642 seconds.
```
Iniciamos de nuevo el nodo.
```
systemctl start duniter
```
## Instalar y configurar el servidor web
Instalamos.
```
apt install nginx
```
Configuramos.
```
vim /etc/nginx/nginx.conf
```
Con el contenido.
```
user www-data;
worker_processes auto;
worker_rlimit_nofile 20480;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 5120;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
}
```
### Configuramos los archivos para HTTPS
Generamos el archivo ssl-dhparams.pem
```
openssl dhparam -dsaparam -out /etc/letsencrypt/ssl-dhparams.pem 4096
```
Editamos el archivo:
```
vim /etc/letsencrypt/options-ssl-nginx.conf
```
Con el contenido.
```
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
```
Editamos el archivo:
```
vim /etc/letsencrypt/certbot.conf
```
Con el contenido. Aquí van las rutas completas a los certificados creados previamente.
```
ssl_certificate /etc/letsencrypt/live/fania.g1server.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/fania.g1server.net/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
```
Editamos el archivo:
```
vim /etc/nginx/sites-available/fania.g1server.net.conf
```
Con el contenido:
```
server {
listen 443 ssl http2;
server_name fania.g1server.net;
include /etc/letsencrypt/certbot.conf;
proxy_set_header X-Forwarded-For $remote_addr;
server_tokens off;
access_log /var/log/nginx/duniter.access.log;
error_log /var/log/nginx/duniter.error.log;
location / {
proxy_pass http://127.0.0.1:10901;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /ws2p {
proxy_pass http://127.0.0.1:20901;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
Creamos el vínculo simbólico:
```
ln -s /etc/nginx/sites-available/fania.g1server.net.conf /etc/nginx/sites-enabled/
```
Borramos el servidor predeterminado.
```
rm /etc/nginx/sites-enabled/default
```
Probamos la configuración
```
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```
### Para tener acceso a la versión web del nodo.
Para no editar el archivo original del servicio, creamos un segundo archivo.
Creamos el directorio.
```
mkdir -p /etc/systemd/system/duniter.service.d/
```
Editamos el archivo.
```
vim /etc/systemd/system/duniter.service.d/10-web.conf
```
Con este contenido.
```
[Service]
Environment="DUNITER_WEB=web"
```
Recargamos la configuración
```
systemctl daemon-reload
```
Reiniciamos el servicio.
```
systemctl restart duniter
```
Lo activamos para que inicie al arrancar el servidor.
```
systemctl enable duniter
```
## Comprobando
Instalamos la herramienta.
```
apt install net-tools
```
Verificamos los puertos abiertos.
```
netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:10901 0.0.0.0:* LISTEN 1330/duniter_defaul
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 757/sshd: /usr/sbin
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 568/systemd-resolve
tcp 0 0 127.0.0.1:20901 0.0.0.0:* LISTEN 1330/duniter_defaul
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1274/nginx: master
tcp 0 0 127.0.0.1:9220 0.0.0.0:* LISTEN 1330/duniter_defaul
tcp6 0 0 :::22 :::* LISTEN 757/sshd: /usr/sbin
```
Si accedes a tu dominio, debes de devolver un json.
```
{
"duniter": {
"software": "duniter",
"version": "1.8.6",
"forkWindowSize": 100
}
}
```
Dado que activamos la interfaz web, pero no esta configurado el acceso en nginx, puedes acceder desde tu maquina redireccionando los puertos.
```
ssh -L 9220:127.0.0.1:9220 -p22 root@fania.g1server.net
```
Una vez conectado, entra desde tu navegador a:
```
http://127.0.0.1:9220
```
Si vez la interfaz web de tu nodo, felicidades, ya deberías verlo listado en el cliente Cesium.
## Recomendaciones finales
Siempre activa el firewall y deja abiertos solo los puertos necesarios. Cambia el puerto predeterminado SSH. Agrega un nuevo usuario con derechos de administrador y deshabilita el acceso a root.
```
ufw allow ssh
ufw allow http
ufw allow https
ufw allow 10901/tcp
ufw allow 20901/tcp
ufw enable
```
Siempre puedes revisar el archivo de configuración en:
```
/var/lib/duniter/.config/duniter/duniter_default/conf.json
```
Gracias por ayudar a ampliar la red G1.
Si este manual te ha sido útil, puedes hacer tu "aprecio" a:
```
A5DdXxCKPw3QKWVdDVs7CzkNugNUW1sHu5zDJFWxCU2h
```
Gracias

View File

@ -0,0 +1,638 @@
# Instalar Duniter Server en Ubuntu Server 22.04 con Docker
## Requerimientos previos
* Al menos 2 CPUs y 3 GB de Ram, mejor 4 CPUs y 4 GB de Ram.
* Un VPS recien instalado, si sabes lo que haces, puede ser uno existente.
* Una IP pública.
* Un dominio o subdominio ya apuntando a tu IP, procura hacerlo un par de horas antes para que se propague correctamente. Si no tienes un subdominio para tu nodo, puedes pedirme uno.
* Un correo electrónico para configurar Let's Encrypt
Vamos a hacer una instalación completa, es decir, con todos los pasos necesarios para que, tal vez, incluso gente con conocimientos básicos pueda seguir la guía.
A menos que sepas lo que haces, no continues si obtienes un error en algún comando, es mejor que me consultes acerca de dicho error.
## Configuración inicial del servidor.
* Conectarse al servidor, en general al instalar te dan acceso al puerto predeterminado que es el 22.
```
ssh -p22 root@IP_DEL_SERVIDOR
```
* Cambia la contraseña predeterminada, siempre es mejor usar un administrador de contraseñas.
```
passwd
New password:
Retype new password:
passwd: password updated successfully
```
* Agrega un nuevo usuario, reemplaza USER por tu usuario.
```
adduser USER
```
* Agrega el usuario al grupo "sudo".
```
gpasswd -a USER sudo
```
* Cambia el puerto predeterminado del servidor SSH
```
vim /etc/ssh/sshd_config
```
* Y reinicia el servicio.
```
systemctl restart ssh
```
* Sal de servidor.
```
CTRL+D
```
## Generar certificado y subir al servidor
* Genera un nuevo certificado si no tienes. Usa tu correo o algún otro comentario.
```
ssh-keygen -t ed25519 -C "usuario@correo.com"
Enter file in which to save the key (/home/mau/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mau/.ssh/id_ed25519
Your public key has been saved in /home/mau/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:5CyKdofJghHDV7EhP3CrxmWC6++ybssCzZBrsNk+K58 usuario@correo.com
The key's randomart image is:
+--[ED25519 256]--+
| o =. |
|. . * + |
|o+ o B . |
|+o+ = .+ |
|oX + . S |
|*+=o + . |
|+o+ * . |
|++++ . |
|+BE= |
+----[SHA256]-----+
```
* Copiamos el certificado publico al servidor.
```
ssh-copy-id -i .ssh/id_ed25519.pub USER@IP_DEL_SERVIDOR
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
user@IP_DEL_SERVIDOR's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'IP_DEL_SERVIDOR'"
and check to make sure that only the key(s) you wanted were added.
```
* Ahora deberías poder conectarte sin contraseña.
```
ssh user@IP_DEL_SERVIDOR
```
## Continuación de la configuración del servidor
* Valida que eres sudo poniendo al día el servidor.
```
sudo apt update
sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
```
* Ponemos bonito el prompt del shell
```
nano .bashrc
```
* Agregamos al final del archivo.
```
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;1m\]}\n└──> \[\e[0m\]"
```
* Guardamos (CTRL+O) y salimos (CTRL+X)
* Activamos los cambios.
```
source .bashrc
```
* Establecemos el hostname con tu dominio, veras el cambio hasta volver a identificarte.
```
sudo hostnamectl set-hostname DOMINIO
```
* Editamos el archivo
```
sudo nano /etc/hosts
127.0.0.1 DOMINIO localhost
```
* Establecemos el uso horario, puedes usar el predeterminado sin problemas que es UTC.
```
sudo timedatectl set-timezone America/Mexico_City
```
* Establecemos locales
```
sudo localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
```
* Agregamos las variables de entorno al archivo.
```
sudo nano /etc/environment
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
```
* Regeneramos locales
```
sudo dpkg-reconfigure locales
Generating locales (this might take a while)...
en_US.UTF-8... done
Generation complete.
```
* Configuramos el servidor SSH
Mejoramos la seguridad del servidor SSH, *CUIDADO*, una mala configuración de este archivo puede dejarte sin acceso al servidor, revisa todo muy bien varias veces.
Dado que solo permitiremos el acceso a tu usuario, ASEGURATE de reemplazar USER por tu usuario, si no lo haces y reinicias el servicio, te quedaras sin acceso al servidor. Toma nota que también estamos desactivamente el acceso a "root" y desactivando el acceso por contraseña, esto quiere decir que solo podrás acceder con los certificados configurados anteriormente. CUIDADO con este paso.
```
sudo nano /etc/ssh/sshd_config
Port 2274
AllowUsers USER
PermitRootLogin no
LoginGraceTime 1m
ClientAliveInterval 600
ClientAliveCountMax 0
MaxAuthTries 3
IgnoreRhosts yes
PermitEmptyPasswords no
PasswordAuthentication no
LogLevel INFO
```
* Reinicimos el servicio, asegurate que todo este bien.
```
sudo systemctl restart ssh
```
* Sal del servidor y vuelve a entrar para validar que todo esta bien.
* Desactivamos los mensajes de Ubuntu al entrar
```
sudo chmod -x /etc/update-motd.d/50-motd-news
sudo chmod -x /etc/update-motd.d/00-header
sudo chmod -x /etc/update-motd.d/10-help-text
```
## Instalar certbot
```
sudo apt install certbot
```
* Nos registramos, reemplaza EMAIL por tu correo electrónico.
```
sudo certbot register --agree-tos -m EMAIL
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Account registered.
```
* Solicitamos el certificado para nuestro DOMINIO. Si no esta registrada correctamente la entrada en los DNS de tu proveedor de dominio aputando a la IP de tu servidor, NO podrás obtener tu certificado con este método.
```
sudo certbot certonly --standalone --preferred-challenges http-01 -d DOMINIO
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for juna.g1server.net
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/juna.g1server.net/fullchain.pem
Key is saved at: /etc/letsencrypt/live/juna.g1server.net/privkey.pem
This certificate expires on 2022-07-28.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
```
* Toma nota de la ubicación de tus certificados.
```
/etc/letsencrypt/live/juna.g1server.net/fullchain.pem
/etc/letsencrypt/live/juna.g1server.net/privkey.pem
```
* Generamos el archivo ssl-dhparams.pem
```
sudo openssl dhparam -dsaparam -out /etc/letsencrypt/ssl-dhparams.pem 4096
Generating DSA parameters, 4096 bit long prime
...
.........+++++++++++++++++++++++++++++++++++*
```
* Creamos el archivo options-ssl-nginx.conf
```
sudo nano /etc/letsencrypt/options-ssl-nginx.conf
```
* Con este contenido
```
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
```
* Creamos el archivo: certbot.conf
```
sudo nano /etc/letsencrypt/certbot.conf
```
* Con este contenido. Asegurate de usar las rutas correctas a los certificados anotadas en los pasos anteriores.
```
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
```
## Instalar Docker
```
sudo apt install docker.io
```
* Verifica que este corriendo el servicio.
```
sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-29 18:58:07 CDT; 1min 29s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 770 (dockerd)
Tasks: 9
Memory: 102.1M
CPU: 374ms
CGroup: /system.slice/docker.service
└─770 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
```
* Nos agregamos al grupo "docker" para no necesitar sudo.
```
sudo usermod -aG docker $USER
```
* Sal y vuelve a identificarte en el servidor para que surta efecto el cambi.
## Instalamos Duniter
* Obtenemos la imagen con la última versión
```
docker pull duniter/duniter
Using default tag: latest
latest: Pulling from duniter/duniter
ddad3d7c1e96: Pull complete
de915e575d22: Pull complete
7150aa69525b: Pull complete
d7aa47be044e: Pull complete
72276961de3c: Pull complete
8a041b0e5a8a: Pull complete
66fb88d067ec: Pull complete
6ee9ba523072: Pull complete
Digest: sha256:c5ef0393f2efedb55052d06a2d43c7a9f65cfaabae72c8cae86b5010c62eb428
Status: Downloaded newer image for duniter/duniter:latest
docker.io/duniter/duniter:latest
```
* Ejecutamos
```
docker run -d -p127.0.0.1:9220:9220 -p10901:10901 -p20901:20901 --mount type=volume,src=duniter-db,dst=/var/lib/duniter --name duniter duniter/duniter
docker run -d -p127.0.0.1:9220:9220 -p127.0.0.1:10901:10901 -p127.0.0.1:20901:20901 --mount type=volume,src=duniter-db,dst=/var/lib/duniter --name duniter duniter/duniter
3521dec590f46b4265b0dba7243b925f1c3bd8f8d0a32ac43a0f479d94145bf4
```
* Inicializamos la configuración.
```
docker exec -it duniter duniter config
2022-04-29T03:46:39+00:00 - debug: Plugging file system...
2022-04-29T03:46:39+00:00 - debug: Loading conf...
2022-04-29T03:46:39+00:00 - debug: Configuration saved.
```
* Establecer tus claves Cesium
Este paso es necesario para establecer tus credenciales de acceso a Cesium cuando se es miembro de la red de confianza y permite escribir en la cadena de bloques. Si no eres miembro el nodo será solo espejo.
```
docker exec -it duniter duniter wizard key
2022-04-29T03:49:30+00:00 - debug: Plugging file system...
2022-04-29T03:49:30+00:00 - debug: Loading conf...
2022-04-29T03:49:30+00:00 - debug: Configuration saved.
? This node's current public key is: Gfhjon3nBAzPTEUdsQTLMqEZBKHkVtn49kjGtCqu2XVb
Modify your keypair? Yes
? Key's salt [hidden]
? Key's password [hidden]
2022-04-29T03:49:54+00:00 - debug: Configuration saved.
```
* Configuramos la red.
El asistente debería mostrarte correctamente tu IP pública, usa las teclas de dirección para seleccionarla.
```
docker exec -it duniter duniter wizard network
2022-04-29T03:51:28+00:00 - debug: Plugging file system...
2022-04-29T03:51:28+00:00 - debug: Loading conf...
2022-04-29T03:51:28+00:00 - debug: Configuration saved.
? IPv4 interface lo 127.0.0.1
? IPv6 interface None
? Port 10901
? Remote IPv4 eth0 IP_PUBLICA
? Remote port 443
? Does this server has a DNS name? Yes
? DNS name: g1.cuates.net
2022-04-29T03:52:37+00:00 - debug: Configuration saved.
```
* Activamos BMA
```
docker exec -it duniter duniter config --addep "BMAS duniter.g1server.net 443"
2022-04-29T03:56:14+00:00 - debug: Plugging file system...
2022-04-29T03:56:14+00:00 - debug: Loading conf...
2022-04-29T03:56:14+00:00 - debug: Configuration saved.
```
* Activamos WS2P
```
docker exec -it duniter duniter config --ws2p-remote-host duniter.g1server.net
2022-04-29T03:57:12+00:00 - debug: Plugging file system...
2022-04-29T03:57:12+00:00 - debug: Loading conf...
2022-04-29T03:57:12+00:00 - debug: Configuration saved.
```
* Configuramos WS2P
```
docker exec -it duniter duniter config --ws2p-public --ws2p-noupnp --ws2p-port 20901 --ws2p-host 127.0.0.1 --ws2p-remote-port 443 --ws2p-remote-host duniter.g1server.net --ws2p-remote-path "/ws2p"
2022-04-29T03:58:53+00:00 - debug: Plugging file system...
2022-04-29T03:58:53+00:00 - debug: Loading conf...
2022-04-29T03:58:53+00:00 - debug: Configuration saved.
```
* Sincronizamos la cadena de bloques.
Dependiendo de la velocidad de la conexión en tu VPS y de la de escritura en su disco, el proceso puede durar entre 1 y 3 horas.
```
docker exec -it duniter duniter sync g1.duniter.org:443
Progress:
Milestones: [||||||||||||||||||||] 100 %
Download: [||||||||||||||||||||] 100 %
Apply: [||||||||||||||||||||] 100 %
Sandbox: [ ] 0 %
Peers: [||||||||||||||||||||] 100 %
Status: Peer TENGx7WtzFsTXwnbrPEvb6odX2WnqYcnnrjiiLvp1mS
All done in 5348.704 seconds.
```
## Instalar y configurar Nginx
```
sudo apt install nginx
```
* Editar el archivo nginx.conf
```
sudo nano /etc/nginx/nginx.conf
```
* Con este contenido
```
user www-data;
worker_processes auto;
worker_rlimit_nofile 20480;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 5120;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
client_max_body_size 50m;
}
```
* Borramos el archivo predeterminado
```
sudo rm /etc/nginx/sites-enabled/default
```
* Agregamos el archivo
```
sudo nano /etc/nginx/sites-available/DOMINIO.conf
```
* Con este contenido
Reemplaza DOMINIO por tu dominio real.
```
server {
listen 443 ssl http2;
server_name DOMINIO;
include /etc/letsencrypt/certbot.conf;
proxy_set_header X-Forwarded-For $remote_addr;
server_tokens off;
access_log /var/log/nginx/DOMINIO.access.log;
error_log /var/log/nginx/DOMINIO.error.log;
location / {
proxy_pass http://127.0.0.1:10901;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /ws2p {
proxy_pass http://127.0.0.1:20901;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
* Creamos el siguiente vínculos simbolico.
```
sudo ln -s /etc/nginx/sites-available/DOMINIO.conf /etc/nginx/sites-enabled/
```
* Probamos la configuración
```
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```
* Reiniciamos el servicio
```
sudo systemctl restart nginx
```
## Reinicar nodo
```
docker stop duniter
docker start duniter
```
## Comprobando
Si accedes a tu dominio
https://duniter.g1server.net/#/app/network
deberías de obtener un json con la versión del server
```
{
"duniter": {
"software": "duniter",
"version": "1.8.2",
"forkWindowSize": 100
}
}
```
Si lo ves en la lista de nodos en Cesium, felicidades.

View File

@ -3,9 +3,46 @@
Gitea es una servidor git.
### Descargar
```
```
git --version
git version 2.34.1
sudo apt install postgresql
sudo vim /etc/postgresql/14/main/pg_hba.conf
local all postgres trust
local all all scram-sha-256
sudo systemctl restart postgresql
psql -U postgres
create role gitea with login encrypted password 'LETMEIN';
create database gitea with owner gitea;
adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /opt/gitea git
mkdir -p /opt/forgejo/{custom,data,log}
chown -R git:git /opt/forgejo/
chmod -R 750 /opt/forgejo/
mkdir /etc/forgejo
chown root:git /etc/forgejo
chmod 770 /etc/forgejo
chmod +x forgejo
sudo cp forgejo /usr/local/bin/forgejo
sudo systemctl enable forgejo --now

19
source/notes/gnunet.gmi Normal file
View File

@ -0,0 +1,19 @@
# Instalar GNUnet
sudo pacman -S libextractor libmicrohttpd
git clone https://aur.archlinux.org/gnurl.git
cd gnurl
makepkg
sudo pacman -U gnurl-7.72.0-1-x86_64.pkg.tar.zst
git clone https://aur.archlinux.org/gnunet.git
cd gnunet
makepkg --skippgpcheck
sudo pacman -U gnunet-0.17.1-1-x86_64.pkg.tar.zst

View File

@ -1,5 +1,19 @@
## iRedMail
* Crear alias
```
psql -U postgres
\c vmail
INSERT INTO alias (address, domain, active)
VALUES('alias@dominio.net', 'dominio.net', 1);
INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_list, active)
VALUES ('alias@dominio.net', 'correo@destino.net', 'dominio.net', 'destino.net', 1, 1)
```
* Manejar listas con
```

View File

@ -41,8 +41,9 @@ host 188.68.36.124
124.36.68.188.in-addr.arpa domain name pointer mail.correolibre.org.
```
Dependiendo de la velocidad de propagación de los servidores de tu proveedor, los cambios en los registros pueden ser más o menos rápidos, sobre todo la configuración del DNS inverso, no continue mientras no tengas estos registros correctamente establecidos.
El instalador de iRedMail solo funciona en un servidor limpio, para este ejemplo he usado un VPS con Ubuntu Server 20.04. La mayor parte de los procesos como root.
El instalador de iRedMail solo funciona en un servidor limpio, para este ejemplo he usado un VPS con Ubuntu Server 22.04. La mayor parte de los procesos como root.
Pon al día el servidor en cuanto a actualizaciones.
```
@ -58,8 +59,6 @@ timedatectl set-timezone America/Mexico_City
Desactiva los locales no usados
```
vim /var/lib/locales/supported.d/en
dpkg-reconfigure locales
localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
@ -75,23 +74,10 @@ Instalar estos paquetes
apt install python-is-python3 mlocate
```
Opcional si quieres cambiar el prompt
```
vim .bashrc
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;1m\]}\n└──> \[\e[0m\]"
source .bashrc
```
Establecer correctamente tu hostname es muy importante para que todo funciona, no uses solo el nombre de tu dominio.
```
hostnamectl set-hostname mail.correolibre.org
cat /etc/hostname
mail.correolibre.org
vim /etc/hosts
127.0.0.1 mail.cuates.net mail localhost
@ -109,14 +95,14 @@ cd /root
Descargamos al última versión del instalador.
```
wget https://github.com/iredmail/iRedMail/archive/1.4.2.tar.gz
wget https://github.com/iredmail/iRedMail/archive/refs/tags/1.6.0.tar.gz
```
Descomprimimos y entramos en el directorio.
```
tar zxf 1.4.2.tar.gz
tar zxf 1.6.0.tar.gz
cd iRedMail-1.4.2/
cd iRedMail-1.6.0/
```
Iniciamos el instalador.
@ -124,6 +110,16 @@ Iniciamos el instalador.
bash iRedMail.sh
```
Presionar Enter en las dos opciones.
```
Adding component(s) 'multiverse' to all repositories.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding component(s) 'universe' to all repositories.
Press [ENTER] to continue or Ctrl-c to cancel.
```
Debe de inciar el asistente de instalación, puedes usar el ratón para seleccionar la opción indicada y dar siguiente cuando corresponda:
1] Pantalla de bienvenida: Yes
2] Directorio de almacenamiento de los buzones de correo: /var/vmail
3] Instalar servidor web: Nginx
@ -131,7 +127,7 @@ bash iRedMail.sh
5] Contraseña para admin PostgreSQL:
6] Capturar primer dominio: correolibre.org
7] Contraseña para el administrador:
8] Componentes opcionales: seleccionar todos.
8] Componentes opcionales: seleccionar todos, excepto SoGo
Después del último paso, debes de ver una confirmación con las opciones seleccionadas.
```
@ -142,7 +138,7 @@ Después del último paso, debes de ver una confirmación con las opciones selec
* Below file contains sensitive infomation (username/password), please *
* do remember to *MOVE* it to a safe place after installation. *
* *
* * /root/iRedMail-1.4.2/config
* * /root/iRedMail-1.6.0/config
* *
*************************************************************************
********************** Review your settings *****************************
@ -155,20 +151,20 @@ Después del último paso, debes de ver una confirmación con las opciones selec
* Web server: Nginx
* First mail domain name: correolibre.org
* Mail domain admin: postmaster@correolibre.org
* Additional components: Roundcubemail SOGo netdata iRedAdmin Fail2ban
* Additional components: Roundcubemail netdata iRedAdmin Fail2ban
< Question > Continue? [y|N]
```
Escribe "y" Enter para continuar. Debe comenzar todo el proceso de descarga, instalación y configuración de todos los paquetes necesarios. En esta prueba el proceso tardo 5 minutos en un VPS con 2 cores y 8 de RAM.
Antes de terminar, puede que veas un mensaje como el siguinte, tal vez solo si cambiaste el puerto predeterminado SSH, si no lo ves, esta bien.
Antes de terminar, puede que veas un mensaje como el siguiente, tal vez solo si cambiaste el puerto predeterminado SSH, si no lo ves, esta bien.
```
< Question > Would you like to use firewall rules provided by iRedMail?
< Question > File: /etc/nftables.conf, with SSHD ports: 2222. [Y|n]Y
< Question > File: /etc/nftables.conf, with SSHD ports: 22. [Y|n]Y
[ INFO ] Copy firewall sample rules.
< Question > Restart firewall now (with ssh ports: 2222)? [y|N]y
< Question > Restart firewall now (with ssh ports: 22)? [y|N]y
[ INFO ] Restarting firewall ...
```
@ -178,7 +174,6 @@ Al terminar, debes de ver un mensaje como este:
* URLs of installed web applications:
*
* - Roundcube webmail: https://mail.correolibre.org/mail/
* - SOGo groupware: https://mail.correolibre.org/SOGo/
* - netdata (monitor): https://mail.correolibre.org/netdata/
*
* - Web admin panel (iRedAdmin): https://mail.correolibre.org/iredadmin/
@ -193,7 +188,7 @@ Al terminar, debes de ver un mensaje como este:
* Congratulations, mail server setup completed successfully. Please
* read below file for more information:
*
* - /root/iRedMail-1.4.2/iRedMail.tips
* - /root/iRedMail-1.6.0/iRedMail.tips
*
* And it's sent to your mail account postmaster@correolibre.org.
*
@ -204,19 +199,19 @@ Al terminar, debes de ver un mensaje como este:
********************************************************************
```
Tal como dice, reinicia el servidor para activar todos los servicios. Toma nota de las credenciales del usuario: "postmaster@correolibre.org" son las predeterminadas para todos los servicios y el usuario administrador de todo.
Tal como dice el mensaje, reinicia el servidor para activar todos los servicios. Toma nota de las credenciales del usuario: "postmaster@correolibre.org" son las predeterminadas para todos los servicios y el usuario administrador de todo.
```
reboot
```
Este archivo contiene información sensible, muevelo a un lugar seguro.
```
/root/iRedMail-1.4.2/config
/root/iRedMail-1.6.0/config
```
Este archivo contiene información importante del servidor, tenlo a la mano para consulta.
```
/root/iRedMail-1.4.2/iRedMail.tips
/root/iRedMail-1.6.0/iRedMail.tips
```
En este momento, el instalador de iRedMail genero certificados autofirmados los cuales funcionan pero la mayoría de los servidores los rechazará. Vamos a reemplazarlos por los gratuitos de Let's Encrypt
@ -290,7 +285,7 @@ nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```
Reiniciamos el servidor web.
Iniciamos de nuevo el servidor web.
```
systemctl start nginx
```
@ -306,11 +301,6 @@ Para el cliente web de correo Roundcube:
https://mail.correolibre.org/mail/
```
Para el cliente web de correo SoGo mi preferido:
```
https://mail.correolibre.org/SOGo/
```
El monitor del sistema NetData:
```
https://mail.correolibre.org/netdata/
@ -323,6 +313,8 @@ amavisd-new showkeys
Copia la clave de modo que quede en una sola línea, ve al administrador de los DNS de tu proveedor de dominio y editar el valor TXT de "dkim._domainkey" con este valor.
CUIDADO: Asegurate de no borrar algún caracter de más al unificarla en una sola línea, cualquier caracter que falte, provocará que sean rechazados los correos, revisala al menos dos veces.
Asegurate de esperar el tiempo suficiente para validarla.
```
amavisd-new testkeys
@ -330,9 +322,9 @@ amavisd-new testkeys
TESTING#1 correolibre.org: dkim._domainkey.correolibre.org => pass
```
Algunos procedimientos especials, requieren editar algunas tablas en la base de datos, para esto, nos aseguramos de poner como de confianza el acceso al usuario "postgres" localmente.
Algunos procedimientos especiales, requieren editar algunas tablas en la base de datos, para esto, nos aseguramos de poner como de confianza el acceso al usuario "postgres" localmente.
```
vim /etc/postgresql/12/main/pg_hba.conf
vim /etc/postgresql/14/main/pg_hba.conf
local all postgres trust
@ -357,8 +349,8 @@ Reemplaza USER por el usuario que acabas de agregar y establece un puerto altern
```
vim /etc/ssh/sshd_config
Port 2222
AllowUsers USER
Port 22
AllowUsers root USER
PermitRootLogin yes
LoginGraceTime 1m
ClientAliveInterval 600
@ -387,7 +379,7 @@ Si ya tienes una clave para identificarte con un servidor puedes usarla, si no,
ssh-keygen -t ed25519
```
Copiamos al clave publica al servidor. Reemplaza CLAVE por el nombre correcto de tu clave, asegurate que se la pública, la terminada en "pub" y reemplaza el USER por el usuario e IP_SERVER por la IP de tu servidor y captura la contraseña cuando se te solicite.
Copiamos la clave publica al servidor. Reemplaza CLAVE por el nombre correcto de tu clave, asegurate que se la pública, la terminada en "pub" y reemplaza el USER por el usuario e IP_SERVER por la IP de tu servidor y captura la contraseña cuando se te solicite.
```
ssh-copy-id -i ~/.ssh/CLAVE.pub USER@IP_SERVER
@ -424,15 +416,6 @@ Renicia el servidor SSH
sudo systemctl restart ssh
```
Opcional, cambia el prompt. Agrega al final del archivo.
```
vim .bashrc
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;1m\]}\n└──> \[\e[0m\]"
source .bashrc
```
## Para agregar un nuevo dominio al servidor.
Generamos una clave para el nuevo dominio.
@ -462,7 +445,6 @@ sudo vim /etc/amavis/conf.d/50-user
# Add dkim_key here.
dkim_key('correolibre.net', 'dkim', '/var/lib/dkim/correolibre.net.pem');
dkim_key('cuates.net', 'dkim', '/var/lib/dkim/cuates.net.pem');
dkim_key('amigos.email', 'dkim', '/var/lib/dkim/amigos.email.pem');
@dkim_signature_options_bysender_maps = ({
# 'd' defaults to a domain of an author/sender address,

739
source/notes/mastodon.gmi Normal file
View File

@ -0,0 +1,739 @@
## Mastodon
Red social libre y descentralizada de microblogging.
=> https://joinmastodon.org/ Mastodon
Debes de tener ya apuntando un registro DNS tipo A (o AAAA) a tu dominio o subdominio que vayas a usar con Mastodon, para este ejemplo he usado: "social.elmau.net". Si no tienes dominio, puedo ayudarte con un subdominio.
Para este proceso he usado Ubuntu Server 22.04 LTS. También asumo que tienes conocimientos básicos de la terminal Linux con cualquier shell. Aquí uso el editor "vim" para editar los archivos, pero puedes usar cualquier editor de texto plano que te guste y este instalado en tu servidor.
Si activas el registro abierto en tu instancia y quieres recibir las notificaciones por correo, necesitas un servicio SMTP activo y funcionando.
El servidor es un VPS con 2 cores y 2 GB de RAM suficiente para varios usuarios.
### [0] Antes de empezar
Asumo que es un servidor limpio recién instalado y actualizado. Como "root"."
```
apt update
apt upgrade
apt autoremove
```
Asegurate de tener correctamente configurado tu host.
```
hostnamectl set-hostname social.elmau.net
```
Tu zona horaria.
```
timedatectl set-timezone America/Mexico_City
```
Y tus locales
```
localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
```
### [1] Requerimiento previo
```
apt install apt-transport-https
```
### [2] Agregar repositorio para "Node.js"
Version 16.x LTS
```
curl -sL https://deb.nodesource.com/setup_16.x | bash -
apt update
```
### [3] Instalar requerimientos
```
apt install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot libidn11-dev libicu-dev libjemalloc-dev
```
### [4] Instalar "yarn"
```
corepack enable
yarn set version stable
```
### [5] Agregar nuevo usuario
Agregamos al usuario "mastodon".
```
adduser --disabled-login mastodon
```
Y nos cambiamos a el.
```
su - mastodon
```
### [6] Instalamos Ruby
Intalamos "rbenv"
```
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec bash
```
Intalamos "rbenv-build"
```
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
```
Instalamos y establecemos la versión global. Este paso, dependiedo de tu hardware puede ser el más tardado.
```
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.4
rbenv global 3.0.4
```
Intalamos
```
gem install bundler --no-document
```
Salimos del usuario "mastodon"
```
exit
```
### [7] Configuramos la base de datos
Entramos al shell de "postgres"
```
sudo -u postgres psql
```
Creamos el usuarios "mastodon" con el permiso para crear la base de datos.
```
CREATE USER mastodon CREATEDB;
```
Salimos del shell.
```
\q
```
### [8] Instalamos "Mastodon"
Nos cambiamos de usuario.
```
su - mastodon
```
Clonamos el repositorio.
```
git clone https://github.com/tootsuite/mastodon.git live
```
Nos movemos de directorio.
```
cd live
```
Nos cambiamos a la versión más reciente estable.
```
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
```
Configuramos.
```
bundle config deployment 'true'
bundle config without 'development test'
```
Instalamos más requerimientos.
```
bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install --pure-lockfile
```
Iniciamos el asistente de instalación:
```
RAILS_ENV=production bundle exec rake mastodon:setup
```
Es importante tener los siguientes datos, reemplaza por los tuyos y capturalos cuando los solicite el asistente.
Dominio o subdominio
```
Your instance is identified by its domain name. Changing it afterward will break things.
Domain name: social.elmau.net
```
Es posible usar Mastodon para un solo usuario, "N" para este caso.
```
Single user mode disables registrations and redirects the landing page to your public profile.
Do you want to enable single user mode? No
```
No, no estamos usando Docker
```
Are you using Docker to run Mastodon? no
```
La base de datos, en todo solo hay que dar "enter" para aceptar los valores predeterminados. Recuerda, NO se establecio contraseña al usuario de la base de datos.
```
PostgreSQL host: /var/run/postgresql
PostgreSQL port: 5432
Name of PostgreSQL database: mastodon_production
Name of PostgreSQL user: mastodon
Password of PostgreSQL user:
Database configuration works!
```
Redis, igualmente, todos los valores predeterminados.
```
Redis host: localhost
Redis port: 6379
Redis password:
Redis configuration works!
```
Si tu instancia tendrá muchos usuarios, es bueno guardar los archivos en un servicio compatible con S3, para este ejemplo es "N"
```
Do you want to store uploaded files on the cloud? No
```
Envío de notificaciones por correo, solo configura si tienes un servicio SMPT funcionando.
```
Do you want to send e-mails from localhost? No
SMTP server: mail.correolibre.net
SMTP port: 587
SMTP username: notificaciones@cuates.net
SMTP password:
SMTP authentication: plain
SMTP OpenSSL verify mode: none
Enable STARTTLS: always
E-mail address to send e-mails "from": (Mastodon <notifications@social.elmau.net>) notificacionesE-mail address to send e-mails "from": notificaciones@cuates.net
Send a test e-mail with this configuration right now? Yes
Send test e-mail to: test@pruebas.net
```
Guardamos la configuración
```
This configuration will be written to .env.production
Save configuration? Yes
```
Creación de la base de datos:
```
Now that configuration is saved, the database schema must be loaded.
If the database already exists, this will erase its contents.
Prepare the database now? Yes
Running `RAILS_ENV=production rails db:setup` ...
Created database 'mastodon_production'
Done!
```
Compilación de los assets CSS/JS
```
The final step is compiling CSS/JS assets.
This may take a while and consume a lot of RAM.
Compile the assets now? Yes
Compiling...
Compiled all packs in /home/mastodon/live/public/packs
Done!
All done! You can now power on the Mastodon server
```
Por último creamos el usuario administrador.
```
Do you want to create an admin user straight away? Yes
Username: admin
E-mail: admin@correo.net
You can login with the password: ba51b96a328807577793a3d7c5e716a6
You can change your password once you login.
```
"Importante", toma nota de la contraseña generada, cambiala por la de tu preferencia en el primer acceso a la instancia.
Salidos del usuario.
```
exit
```
### [9] Solicitamos los certificados para el dominio con "Certbot"
Detenemos "nginx"
```
systemctl stop nginx
```
Registrar un correo. Utiliza un correo válido, recibirás las notificaciones para cuando estén por vencerse los certificados.
```
certbot register --agree-tos -m YOUR_EMAIL
(Y)es/(N)o: Y
Account registered.
```
Solicitamos los certificados para nuestro dominio. Reemplaza DOMAIN por el dominio o subdominio que estés usando.
```
certbot certonly --standalone --preferred-challenges http-01 -d DOMAIN
```
Si todo esta bien, debes de ver un mensaje similar a:
```
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/DOMAIN/fullchain.pem
Key is saved at: /etc/letsencrypt/live/DOMAIN/privkey.pem
This certificate expires on 2023-02-13.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
```
Toma nota de las rutas completas de tus nuevos certificados.
```
/etc/letsencrypt/live/social.elmau.net/fullchain.pem
/etc/letsencrypt/live/social.elmau.net/privkey.pem
```
### [10] Configuramos archivos para HTTPS.
Crear archivo "ssl-dhparams.pem"
```
openssl dhparam -dsaparam -out /etc/letsencrypt/ssl-dhparams.pem 4096
```
Crear el archivo "options-ssl-nginx.conf"
```
vim /etc/letsencrypt/options-ssl-nginx.conf
```
Con el siguiente contenido:
```
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
```
Crear el archivo "certbot.conf"
```
vim /etc/letsencrypt/certbot.conf
```
Con el siguiente contenido. Asegurate de reemplazar "social.elmau.net" por tu dominio.
```
ssl_certificate /etc/letsencrypt/live/social.elmau.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/social.elmau.net/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
```
### [11] Configuramos "nginx"
Borramos el servidor predeterminado.
```
rm /etc/nginx/sites-enabled/default
```
Reemplazar el contenido del archivo "nginx.conf"
```
vim /etc/nginx/nginx.conf
```
Por:
```
user www-data;
worker_processes auto;
worker_rlimit_nofile 20480;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 5120;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
keepalive_timeout 60;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
}
```
Configurar el dominio en el archivo "social.elmau.conf", no olvides reemplazar por tu dominio o subdominio.
```
vim /etc/nginx/sites-available/social.elmau.conf
```
Con el siguiente contenido. Reemplazar "social.elmau.conf" donde corresponda:
```
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream backend {
server 127.0.0.1:3000 fail_timeout=0;
}
upstream streaming {
server 127.0.0.1:4000 fail_timeout=0;
}
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;
server {
listen 80;
listen [::]:80;
server_name social.elmau.net;
root /home/mastodon/live/public;
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name social.elmau.net;
charset utf-8;
keepalive_timeout 70;
sendfile on;
client_max_body_size 80m;
include /etc/letsencrypt/certbot.conf;
#proxy_set_header X-Forwarded-For $remote_addr;
server_tokens off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /home/mastodon/live/public;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml image/x-icon;
location / {
try_files $uri @proxy;
}
# If Docker is used for deployment and Rails serves static files,
# then needed must replace line `try_files $uri =404;` with `try_files $uri @proxy;`.
location = /sw.js {
add_header Cache-Control "public, max-age=604800, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/assets/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/avatars/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/emoji/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/headers/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/packs/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/shortcuts/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/sounds/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/system/ {
add_header Cache-Control "public, max-age=2419200, immutable";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ^~ /api/v1/streaming {
proxy_set_header Host $host;
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 $scheme;
proxy_set_header Proxy "";
proxy_pass http://streaming;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
tcp_nodelay on;
}
location @proxy {
proxy_set_header Host $host;
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 $scheme;
proxy_set_header Proxy "";
proxy_pass_header Server;
proxy_pass http://backend;
proxy_buffering on;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache CACHE;
proxy_cache_valid 200 7d;
proxy_cache_valid 410 24h;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
add_header X-Cached $upstream_cache_status;
tcp_nodelay on;
}
error_page 404 500 501 502 503 504 /500.html;
}
```
Creamos el vínculo simbólico.
```
ln -s /etc/nginx/sites-available/social.elmau.conf /etc/nginx/sites-enabled/
```
Probamos la configuración.
```
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```
Solo, si no obtienes un error, inicia el servicio.
```
systemctl start nginx
```
### [12] Configuramos los servicios para Mastodon
Editamos el archivo "mastodon-web.service"
```
vim /etc/systemd/system/mastodon-web.service
```
Con el siguiente contenido.
```
[Unit]
Description=mastodon-web
After=network.target
[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="RAILS_ENV=production"
Environment="PORT=3000"
ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb
ExecReload=/bin/kill -SIGUSR1 $MAINPID
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
```
Editamos el archivo "mastodon-sidekiq.service"
```
vim /etc/systemd/system/mastodon-sidekiq.service
```
Con el siguiente contenido.
```
[Unit]
Description=mastodon-sidekiq
After=network.target
[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="RAILS_ENV=production"
Environment="DB_POOL=25"
Environment="MALLOC_ARENA_MAX=2"
ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 25
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
```
Editamos el archivo "mastodon-streaming.service"
```
vim /etc/systemd/system/mastodon-streaming.service
```
Con el siguiente contenido.
```
[Unit]
Description=mastodon-streaming
After=network.target
[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="NODE_ENV=production"
Environment="PORT=4000"
Environment="STREAMING_CLUSTER_NUM=1"
ExecStart=/usr/bin/node ./streaming
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
```
Recargamos
```
systemctl daemon-reload
```
Activamos e iniciamos los servicio.
```
systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming
```
Asegurate que cada servicio este activo sin errores.
```
systemctl status mastodon-web
systemctl status mastodon-sidekiq
systemctl status mastodon-streaming
```
### [13] Permisos
Agregamos estos usuarios a estos grupos.
```
usermod -a -G mastodon www-data
usermod -a -G www-data mastodon
```
### [14] Reniciamos
La mejor forma de verificar que todos los servicios arrancan bien, es reinciando el servidor.
```
reboot
```
### [15] Recomendaciones finales.
Activa el firewall.
```
ufw allow http
ufw allow https
ufw allow ssh
ufw enable
```
Configura el servidor SSH para desactivar el acceso "root" y la identificación por contraseña, solo acceder con certificados que tu hayas generado.
Instala "file2ban"
Si este tutorial te ha sido útil considera hacer un aprecio al mismo:
En Junas (G1)
```
A5DdXxCKPw3QKWVdDVs7CzkNugNUW1sHu5zDJFWxCU2h
```
En Euros:
```
IBAN: BE60 9671 0556 5870
SWIFT / BIC: TRWIBEB1XXX
```
Gracias

View File

@ -1,42 +1,319 @@
## Matrix
## Matrix en Ubuntu Server 22.04
Matrix es un excelente software de chat desentralizado.
Matrix es un excelente software de chat descentralizado.
Si bien se puede tener un dominio como nombre de tu servidor, es más practico usar un subdominio, asegurate de tenerlo ya apuntando a tu servidor.
```
matrix.dominio.net
```
Instalar dependencias
```Instalar dependencias
sudo apt install curl wget gnupg2 apt-transport-https
```
sudo apt install gnupg2 apt-transport-https
```
Agregar la firma de los paquetes
```Agregar la firma de los paquetes
```
sudo wget -qO /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg
```
Agregar el repositorio
```Agregar el repositorio
sudo echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/matrix-org.list
```
echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/matrix-org.list
```
Actualizamos el repositorio
```
sudo apt update
```
Instalar el servidor
```Instalar el servidor
```
sudo apt install matrix-synapse-py3
```
Agrega el nombre de tu servidor (matriz.dominio.net) sin ningún protocolo cuando se te solicite.
Agrega el nombre de tu servidor (matrix.dominio.net) sin ningún protocolo cuando se te solicite.
Instalar Postgres
```
sudo apt install postgresql
```
Configura
```
sudo vim /etc/postgresql/14/main/pg_hba.conf
local all postgres trust
local all all scram-sha-256
```
Reinicia
```
systemctl restart postgresql
```
Entra al shell de postgres
```
psql -U postgres
```
Y creas el role y la base de datos:
```
create role matrix with login encrypted password 'LETMEIN';
create database matrix with owner matrix locale 'C' template template0;
```
Regresa al shell del server.
Vamos a editar la configuración para que use postgres.
```
vim /etc/matrix-synapse/homeserver.yaml
```
Reemplaza en:
```
database:
name: psycopg2
args:
user: matrix
password: LETMEIN
database: matrix
host: localhost
```
Al final agregas:
```
registration_shared_secret: "SUPER-SECRET"
```
Guardas.
Instalamos el driver para postgres:
```
sudo apt install python-is-python3 python3-pip
sudo pip install --upgrade pip wheel
sudo pip install psycopg2-binary
```
Reinicias.
```
systemctl restart matrix-synapse
```
Verifica que todo este bien.
```
systemctl status matrix-synapse
```
Registra un usuario:
```
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml http://localhost:8008
```
Instalamos certbot.
```
apt install certbot
```
Nos registramos.
```
certbot register --agree-tos -m CORREO
```
Solicitamos el certificado.
```
certbot certonly --standalone --preferred-challenges http-01 -d matrix.dominio.net
```
Toma nota de las rutas de los certificados.
Generamos el archivo.
```
openssl dhparam -dsaparam -out /etc/letsencrypt/ssl-dhparams.pem 4096
```
Creamos el archivo.
```
vim /etc/letsencrypt/options-ssl-nginx.conf
```
con este contenido.
``
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
```
Creamos el archivo.
```
vim /etc/letsencrypt/certbot.conf
```
con este contenido.
```
ssl_certificate /etc/letsencrypt/live/matrix.dominio.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/matrix.dominio.net/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
```
Instalamos el servidor web
```
apt install nginx
```
Borramos el archivo.
```
rm /etc/nginx/sites-enabled/default
```
Editamos el archivo.
```
vim /etc/nginx/nginx.conf
```
con el contenido.
```
user www-data;
worker_processes auto;
worker_rlimit_nofile 25600;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 5120;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
client_max_body_size 50m;
}
```
Creamos el archivo
```
vim /etc/nginx/sites-available/matrix.dominio.net.conf
```
con el contenido.
```
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
# For the federation port
listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;
server_name matrix.dominio.net;
charset utf-8;
include /etc/letsencrypt/certbot.conf;
server_tokens off;
access_log /var/log/nginx/matrix.access.log;
error_log /var/log/nginx/matrix.error.log;
location / {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
}
location ~* ^(\/_matrix|\/_synapse\/client) {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
client_max_body_size 10M;
}
}
```
Creamos el vínculo simbólico.
```
ln -s /etc/nginx/sites-available/matrix.dominio.net.conf /etc/nginx/sites-enabled/
```
Probamos la configuración.
```
nginx -t
```
Si todo esta bien, reinicias el servidor web.
```
systemctl restart nginx
```
Ya deberías poder acceder desde cualquier cliente Matrix.
Siempre activa el firewall y deja abiertos solo los puertos necesarios. Cambia el puerto predeterminado SSH. Agrega un nuevo usuario con derechos de administrador y deshabilita el acceso a root.
```
ufw allow ssh
ufw allow https
ufw allow 8448/tcp
ufw enable
```
¡Disfruta!
### Extras
Cambiar la contraseña de un usuario:
```
hash_password -c /etc/matrix-synapse/homeserver.yaml
Password:
Confirm password:
HASH
```
En la base de datos.
```
\c matrix
update users set password_hash='HASH' where name='@USER:matrix.cuates.net';
```
=> gemini://elmau.net/chuletas.gmi Regresar el índice

View File

@ -4,7 +4,6 @@
```Instalar
sudo apt install postgresql
```

View File

@ -1,66 +1,159 @@
## SeaFile
SeaFile es un servidor de archivos.
SeaFile es un servidor de archivos similiar a NextCloud.
=> https://www.seafile.com/en/home/ SeaFile
Debes de tener ya apuntando un registro DNS tipo A a tu dominio o subdominio que vayas a usar con SeaFile, para este ejemplo he usado: seafile.cuates.net
Debes de tener ya apuntando un registro DNS tipo A (o AAAA) a tu dominio o subdominio que vayas a usar con SeaFile, para este ejemplo he usado: "seafile.cuates.net". Si no tienes dominio, puedo ayudarte con un subdominio.
Asumo que es un servidor limpio recien instalado.
Para este proceso he usado Ubuntu Server 22.04 LTS. También asumo que tienes conocimientos básicos de la terminal Linux con cualquier shell. Aquí uso el editor "vim" para editar los archivos, pero puedes usar cualquier editor de texto plano que te guste y este instalado en tu servidor.
* Como root
Si activas el registro abierto en tu instancia y quieres recibir las notificaciones por correo, necesitas un servicio SMTP activo y funcionando.
Agregar el usuario seafile
### [0] Preparación
Asumo que es un servidor limpio recién instalado y actualizado.
```
apt update
apt upgrade
apt autoremove
```
Asegurate de tener correctamente configurado tu host.
```
hostnamectl set-hostname seafile.cuates.net
```
Tu zona horaria.
```
timedatectl set-timezone America/Mexico_City
```
Y tus locales
```
localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
```
### [1] Agregar usuario
Como "root", agregar el usuario "seafile".
```
adduser seafile
```
Y agrégalo al grupo "sudo".
```
usermod -aG sudo seafile
```
* Como seafile
Cambiate a este nuevo usuario.
Instalar los requerimientos.
```
su seafile
```
### [2] Instalar los requerimientos previos.
Estos requerimientos con "sudo".
```
sudo apt install python-is-python3 python3-pip libmemcached-dev memcached python3-dev default-libmysqlclient-dev build-essential
sudo pip3 install --upgrade pip wheel
pip install --user pillow pylibmc captcha jinja2 sqlalchemy django-pylibmc django-simple-captcha python3-ldap mysqlclient
```
Instalar y configurar MariaDB
Actualizamos "pip".
```
sudo pip install --upgrade pip wheel
```
Estos requerimientos ya son sin "sudo".
```
pip install --user pillow pylibmc captcha jinja2 sqlalchemy django-pylibmc django-simple-captcha python3-ldap mysqlclient lxml
```
### [3] Instalar el motor de base de datos MariaDB
Instalar con "sudo".
```
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo mysql -u root -p
use mysql;
update user set plugin='mysql_native_password' where user='root';
flush privileges;
quit;
```
Ejecutar el asistente para mejorar la seguridad de MariaDB
```
sudo mysql_secure_installation
```
Asegurate de que la contraseña para el "root" de MariaDB esta bien.
```
sudo mysql -u root -p
```
### [4] Instalar SeaFile
Creamos el directorio de instalación.
```
sudo mkdir /opt/seafile
```
Lo cambiamos de dueño.
```
sudo chown -R seafile:seafile /opt/seafile
```
Nos movemos a el.
```
cd /opt/seafile
```
wget https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_8.0.7_x86-64.tar.gz
Descargamos la última versión.
```
wget https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_9.0.9_x86-64.tar.gz
```
tar -xzf seafile-server_8.0.7_x86-64.tar.gz
Extraemos.
```
tar -xzf seafile-server_9.0.9_x86-64.tar.gz
```
Creamos un directorio para guardar el archivo descargado.
```
mkdir installed
```
mv seafile-server_8.0.7_x86-64.tar.gz installed/
Y lo movemos.
cd seafile-server-8.0.7
```
mv seafile-server_9.0.9_x86-64.tar.gz installed/
```
Entramos al directorio.
```
cd seafile-server-9.0.9
```
Iniciamos el asistente de instalación de SeaFile.
```
./setup-seafile-mysql.sh
---------------------------------
@ -86,278 +179,548 @@ cd seafile-server-8.0.7
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------
```
No continúes si "no ves" este último mensaje.
Iniciamos "seafile" para comprobar que todo esta bien.
```
./seafile.sh start
```
Seafile server started
Si todo esta bien, debes de ver un mensaje similar a:
```
Starting seafile server, please wait ...
** Message: 19:17:49.928: seafile-controller.c(621): No seafevents.
Seafile server started
Done.
```
Iniciamos "seahub".
```
./seahub.sh start
```
What is the email for the admin account?
[ admin email ]
Como es la primera vez, te solicitará una cuenta de correo que será la cuenta adminstración de la instancia. También te pedirá una contraseña, no uses la misma de tu correo, usa una diferente.
What is the password for the admin account?
[ admin password ]
```
Starting seahub at port 8000 ...
----------------------------------------
Successfully created seafile admin
----------------------------------------
...
Seahub is started
----------------------------------------
It's the first time you start the seafile server. Now let's create the admin account
----------------------------------------
What is the email for the admin account?
[ admin email ] admin@wecommercegroup.com
What is the password for the admin account?
[ admin password ]
Enter the password again:
[ admin password again ]
----------------------------------------
Successfully created seafile admin
----------------------------------------
Seahub is started
Done.
```
Si todo esta bien, es decir, si ves correctamente los mensajes anteriores, detenemos los servicios.
```
./seahub.sh stop
Stopping seahub ...
Done.
./seafile.sh stop
Stopping seafile server ...
Done.
```
### [5] Instalar CertBot
Instalar
```
sudo apt install certbot
```
Registrar un correo. Utiliza un correo válido, recibirás las notificaciones para cuando estén por vencerse los certificados.
```
sudo certbot register --agree-tos -m YOUR_EMAIL
```
Solicitamos los certificados para nuestro dominio. Reemplaza DOMAIN por el dominio o subdominio que estés usando.
```
sudo certbot certonly --standalone --preferred-challenges http-01 -d DOMAIN
```
/etc/letsencrypt/live/DOMAIN/fullchain.pem
/etc/letsencrypt/live/DOMAIN/privkey.pem
Si todo esta bien, debes de ver un mensaje similar a:
```
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/DOMAIN/fullchain.pem
Key is saved at: /etc/letsencrypt/live/DOMAIN/privkey.pem
This certificate expires on 2023-02-13.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
```
Toma nota de las rutas completas de tus nuevos certificados.
```
/etc/letsencrypt/live/DOMAIN/fullchain.pem
/etc/letsencrypt/live/DOMAIN/privkey.pem
```
### [6] Configurar archivos para HTTPS.
Crear archivo "ssl-dhparams.pem"
```
sudo openssl dhparam -dsaparam -out /etc/letsencrypt/ssl-dhparams.pem 4096
```
Crear el archivo "options-ssl-nginx.conf"
```
sudo vim /etc/letsencrypt/options-ssl-nginx.conf
```
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
Con el siguiente contenido:
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
```
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
```
Crear el archivo "certbot.conf"
```
sudo vim /etc/letsencrypt/certbot.conf
```
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
Con el siguiente contenido. Asegurate de reemplazar DOMAIN por tu dominio.
```
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
```
### [7] Instalar y configurar "nginx"
Instalar.
```
sudo apt install nginx
```
Reemplazar el contenido del archivo "nginx.conf"
```
sudo vim /etc/nginx/nginx.conf
```
user www-data;
worker_processes auto;
worker_rlimit_nofile 20480;
pid /run/nginx.pid;
Por:
error_log /var/log/nginx/error.log warn;
```
user www-data;
worker_processes auto;
worker_rlimit_nofile 20480;
pid /run/nginx.pid;
events {
worker_connections 5120;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 5120;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
}
```
Configurar el dominio en el archivo "DOMAIN.conf", no olvides reemplazar DOMAIN por tu dominio o subdominio.
```
sudo vim /etc/nginx/sites-available/DOMAIN.conf
```
Con el siguiente contenido.
```
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name seafile.cuates.net;
charset utf-8;
include /etc/letsencrypt/certbot.conf;
proxy_set_header X-Forwarded-For $remote_addr;
server_tokens off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 1200s;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
client_max_body_size 50m;
include /etc/nginx/badagent.rules;
include /etc/nginx/badreferer.rules;
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
}
sudo vim /etc/nginx/sites-available/seafile.cuates.net.conf
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name seafile.cuates.net;
charset utf-8;
include /etc/letsencrypt/custom/elmau.net/certbot.conf;
proxy_set_header X-Forwarded-For $remote_addr;
server_tokens off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 1200s;
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
}
location /media {
root /opt/seafile/seafile-server-latest/seahub;
}
location /media {
root /opt/seafile/seafile-server-latest/seahub;
}
}
```
Creamos un enlace simbólico al archivo anterior.
```
sudo ln -s /etc/nginx/sites-available/seafile.cuates.net.conf /etc/nginx/sites-enabled/
```
Probamos la configuración.
```
sudo nginx -t
```
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Debes de ver el mensaje siguiente:
```
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```
No continues si obtienes cualquier error.
### [8] Configurar SeaFile
Entramos al directorio.
```
cd /opt/seafile/conf
```
Editamos el archivo "ccnet.conf"
```
vim ccnet.conf
```
[General]
SERVICE_URL = https://seafile.cuates.net
En la sección "General" agregamos:
```
[General]
SERVICE_URL = https://seafile.cuates.net
```
Editamos el archivo "seahub_settings.py"
```
vim seahub_settings.py
```
FILE_SERVER_ROOT = 'https://seafile.elmau.net/seafhttp'
Asegurate de cambiar:
EMAIL_USE_SSL = True
EMAIL_HOST = 'mail.gandi.net'
EMAIL_HOST_USER = 'no-responder@empresalibre.mx'
EMAIL_PORT = 465
EMAIL_USE_LOCALTIME = True
EMAIL_HOST_PASSWORD = 'PASSWORD'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
```
SERVICE_URL = "http://DOMAIN/"
```
ENABLE_SETTINGS_VIA_WEB = False
Por:
ALLOWED_HOSTS = ['seafile.elmau.net']
```
SERVICE_URL = "https://DOMAIN/"
```
ENABLE_SIGNUP = True
Y agregas al final del archivo.
ACTIVATE_AFTER_REGISTRATION = False
```
FILE_SERVER_ROOT = 'https://seafile.cuates.net/seafhttp'
NOTIFY_ADMIN_AFTER_REGISTRATION = True
ENABLE_SETTINGS_VIA_WEB = False
LOGIN_ATTEMPT_LIMIT = 3
ALLOWED_HOSTS = ['seafile.cuates.net']
FREEZE_USER_ON_LOGIN_FAILED = True
TIME_ZONE = 'America/Mexico_City'
USER_PASSWORD_MIN_LENGTH = 10
LANGUAGE_CODE = 'es'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
LANGUAGES = (
('en', 'English'),
('es', 'Español'),
)
TIME_ZONE = 'America/Mexico_City'
SITE_NAME = 'Seafile puros Cuates'
LANGUAGE_CODE = 'en'
SITE_TITLE = SITE_NAME
LANGUAGES = (
('en', 'English'),
('es', 'Español'),
)
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_RATES': {
'ping': '600/minute',
'anon': '5/minute',
'user': '300/minute',
},
'UNICODE_JSON': False,
}
SITE_NAME = 'Seafile Cuates'
EMAIL_USE_SSL = True
EMAIL_HOST = 'mail.gandi.net'
EMAIL_HOST_USER = 'no-responder@correo.email'
EMAIL_PORT = 465
EMAIL_USE_LOCALTIME = True
EMAIL_HOST_PASSWORD = 'SUPER_SECRET_PASSWORD'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
SITE_TITLE = SITE_NAME
ENABLE_SIGNUP = True
SHARE_LINK_EMAIL_LANGUAGE = 'es-ES'
ACTIVATE_AFTER_REGISTRATION = False
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_RATES': {
'ping': '600/minute',
'anon': '5/minute',
'user': '300/minute',
},
'UNICODE_JSON': False,
}
NOTIFY_ADMIN_AFTER_REGISTRATION = True
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
},
}
LOGIN_ATTEMPT_LIMIT = 3
FREEZE_USER_ON_LOGIN_FAILED = True
USER_PASSWORD_MIN_LENGTH = 10
USER_STRONG_PASSWORD_REQUIRED = True
FORCE_PASSWORD_CHANGE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SHARE_LINK_EMAIL_LANGUAGE = 'es-ES'
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
},
}
TEXT_PREVIEW_EXT = """ac, am, bat, c, cc, cmake, cpp, cs, css, diff, el, gmi, h, html,
htm, java, js, json, less, make, org, php, pl, properties, py, rb,
scala, script, sh, sql, txt, text, tex, vi, vim, xhtml, xml, log, csv,
groovy, rst, patch, go"""
```
Editamos el archivo "seafile.conf"
```
vim seafile.conf
```
En la sección "fileserver" comenta las dos líneas:
```
#[fileserver]
#port = 8082
```
Y agrega al final del archivo después de la sección "[database]":
```
[quota]
default = 10
[history]
keep_days = 30
[zip]
windows_encoding = iso-8859-1
[fileserver]
use_go_fileserver = true
```
### [9] Configuramos los servicios para controlar SeaFile
Creamos el archivo "seafile.service"
```
sudo vim /etc/systemd/system/seafile.service
```
[Unit]
Description=Seafile
After=network.target mysql.service
Con el siguiente contenido:
[Service]
Type=forking
ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop
LimitNOFILE=infinity
User=seafile
Group=www-data
```
[Unit]
Description=Seafile
After=network.target mysql.service
[Install]
WantedBy=multi-user.target
[Service]
Type=forking
ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop
LimitNOFILE=infinity
User=seafile
Group=www-data
[Install]
WantedBy=multi-user.target
```
Creamos el archivo "seahub.service"
```
sudo vim /etc/systemd/system/seahub.service
```
[Unit]
Description=Seahub
After=network.target seafile.service
Con el siguiente contenido.
[Service]
Environment="LC_ALL=en_US.UTF-8"
Type=forking
ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start
ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
User=seafile
Group=www-data
```
[Unit]
Description=Seahub
After=network.target seafile.service
[Install]
WantedBy=multi-user.target
[Service]
Environment="LC_ALL=en_US.UTF-8"
Type=forking
ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start
ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
User=seafile
Group=www-data
[Install]
WantedBy=multi-user.target
```
Activamos para que inicien al reiniciar el servidor.
```
sudo systemctl enable seafile
sudo systemctl start seafile
sudo systemctl enable seahub
```
Iniciamos los servicios.
```
sudo systemctl start seafile
sudo systemctl start seahub
```
Verifica que los dos estén activos y funcionando.
```
sudo systemctl status seafile
sudo systemctl status seahub
```
Reiniciamos "nginx"
```
sudo systemctl restart nginx
```
### [10] Instalar y configurar el firewall
Instalamos "ufw", puede que ya este instalado.
```
sudo apt install ufw
```
sudo ufw allow 2274/tcp
Abrimos los puertos necesarios, reemplaza SSH_PORT por el puerto que hayas configurado en tu acceso SSH, no es recomendable dejar el 22 predeterminado.
```
sudo ufw allow SSH_PORT/tcp
sudo ufw allow 443/tcp
```
Asegurate de que el puerto SSH sea el correcto "antes" de activar el firewall, si no es el correcto, puedes perder el acceso a tu servidor.
Lo activamos.
```
sudo ufw enable
```
En este momento, ya deberías tener acceso desde tu dominio o subdominio configurado con las credenciales administrativas configuradas anteriormente.
Ya puedes también, instalar un cliente para sincronizar en tu sistema operativo.
=> https://www.seafile.com/en/download/ Clientes SeaFile
Si este tutorial te ha sido útil considera hacer un aprecio al mismo:
En Junas (G1)
```
A5DdXxCKPw3QKWVdDVs7CzkNugNUW1sHu5zDJFWxCU2h
```
En Euros:
```
IBAN: BE60 9671 0556 5870
SWIFT / BIC: TRWIBEB1XXX
```
Gracias

272
source/notes/searxng.gmi Normal file
View File

@ -0,0 +1,272 @@
## SearXNG
Metabuscador
Instalación en un servidor Ubuntu 20.04 nuevo. Ya debes de tener un dominio o subdominio apuntando a la IP de tu servidor.
### Configuración inicial
* Actualizar el sistema
```
sudo apt update
sudo apt upgrade
```
* Configuración basica
```
localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
vim /etc/environment
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
dpkg-reconfigure locales
hostnamectl set-hostname buscar.cuates.net
vim /etc/hosts
127.0.0.1 buscar.cuates.net localhost
chmod -x /etc/update-motd.d/50-motd-news
chmod -x /etc/update-motd.d/00-header
chmod -x /etc/update-motd.d/10-help-text
vim /etc/security/limits.conf
* soft nofile 20480
vim .bashrc
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;1m\]}\n└──> \[\e[0m\]"
source .bashrc
```
* Instalar requisitos previos.
```
apt install python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev shellcheck
```
* Agregar usuario
```
useradd --shell /bin/bash --system --home-dir "/usr/local/searx" --comment 'Privacy-respecting metasearch engine' searx
mkdir /usr/local/searx
chown -R searx:searx /usr/local/searx
su searx
```
* Clonamos SearXNG
```
git clone https://github.com/searxng/searxng /usr/local/searx/searx-src
```
* Creamos entorno virtual
```
python3 -m venv /usr/local/searx/searx-pyenv
source /usr/local/searx/searx-pyenv/bin/activate
```
* Actualizamos e instalamos dependencias
```
pip install -U pip setuptools wheel pyyaml
cd "/usr/local/searx/searx-src"
pip install -e .
deactivate
exit
```
* Configuramos
```
mkdir -p "/etc/searxng"
cp "/usr/local/searx/searx-src/utils/templates/etc/searxng/settings.yml" "/etc/searxng/settings.yml"
sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "/etc/searxng/settings.yml"
```
* Probamos
```
sudo -H sed -i -e "s/debug: false/debug: true/g" "/etc/searxng/settings.yml"
su searx
source /usr/local/searx/searx-pyenv/bin/activate
cd /usr/local/searx/searx-src
export SEARXNG_SETTINGS_PATH="/etc/searxng/settings.yml"
python searx/webapp.py
```
* Si no se obtiene ningún error.
```
CTRL+C
deactivate
exit
sudo -H sed -i -e "s/debug: true/debug: false/g" "/etc/searxng/settings.yml"
```
* Instalar herramientas restantes
```
cd /usr/local/searx/searx-src
./utils/filtron.sh install all
./utils/morty.sh install all
```
### Instalamos Certbot
* Usa un correo que puedas consultar para registrarte, es importante para las notificaciones de vencimiento del certificado.
```
apt install certbot
certbot register --agree-tos -m YOUR_EMAIL
```
* Solicitamos el certificado, reemplaza DOMAIN por el dominio de tu foro.
```
certbot certonly --standalone --preferred-challenges http-01 -d DOMAIN
/etc/letsencrypt/live/DOMAIN/fullchain.pem
/etc/letsencrypt/live/DOMAIN/privkey.pem
```
* Generamos el archivo: ssl-dhparams.pem
```
openssl dhparam -dsaparam -out /etc/letsencrypt/ssl-dhparams.pem 4096
```
* Creamos el archivo: options-ssl-nginx.conf
```
vim /etc/letsencrypt/options-ssl-nginx.conf
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA38";
add_header Strict-Transport-Security "max-age=63072000; preload";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Permissions-Policy interest-cohort=();
```
* Creamos el archivo: certbot.conf
```
vim /etc/letsencrypt/certbot.conf
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
```
### Instalamos Nginx
```
sudo apt install nginx
```
* Configuración general
```
sudo vim /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
worker_rlimit_nofile 20480;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 5120;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*.conf;
disable_symlinks off;
client_max_body_size 100M;
}
```
* Validamos la configuración.
```
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```
No continues si obtienes cualquier error.
* Reinicia nginx
```
systemctl restart nginx
```
* En tu navegador ver a la URL
```
https://buscar.cuates.net
```
=> gemini://elmau.net/chuletas.gmi Regresar el índice
=> gemini://elmau.net Regresar el inicio

View File

@ -1,4 +1,4 @@
## Ubuntu Server 20.04
## Ubuntu Server 22.04
Agregar un usuario.
@ -38,8 +38,6 @@ sudo vim /etc/environment
Limpiar locales no utilizados
```Limpiar locales no utilizados
sudo vim /var/lib/locales/supported.d/en
sudo dpkg-reconfigure locales
```
@ -48,7 +46,7 @@ Establecer un mejor prompt
```Establecer un mejor prompt
vim .bashrc
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;1m\]}\n└──> \[\e[0m\]"
PS1="┌─[\e[0;32m\H\e[m][\e[1;31m\u\e[m]->{\[\e[34;1m\]\w\[\e[0;0m\]}\n└──> \[\e[0m\]"
source .bashrc
@ -70,17 +68,18 @@ Establecer configuración para `ssh`
sudo vim /etc/ssh/sshd_config
Port 2274
AllowUsers USER
PermitRootLogin no
LoginGraceTime 1m
ClientAliveInterval 600
ClientAliveCountMax 0
MaxAuthTries 3
IgnoreRhosts yes
PermitEmptyPasswords no
PasswordAuthentication no
LogLevel INFO
Port 2274
AllowUsers USER
LoginGraceTime 1m
ClientAliveInterval 600
ClientAliveCountMax 0
MaxAuthTries 3
IgnoreRhosts yes
PermitEmptyPasswords no
LogLevel INFO
PasswordAuthentication no
PermitRootLogin no
sudo systemctl restart ssh
@ -117,6 +116,28 @@ sudo ufw enable
```
* Instalar docker
```
sudo apt update
sudo apt upgrade
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker
sudo usermod -aG docker USERNAME
```
Cambiar limite de archivos abiertos
```Cambiar limite de archivos abiertos