diff --git a/assets/site/scss/_main.scss b/assets/site/scss/_main.scss index 23dfe3e..42b6089 100644 --- a/assets/site/scss/_main.scss +++ b/assets/site/scss/_main.scss @@ -58,6 +58,11 @@ text-transform: uppercase; } +.language-switcher { + font-family: sans-serif; + margin-bottom: 1.5rem; +} + .gravatar { margin: 0.3em 1.2em 1em 0; border-radius: 0.3rem; diff --git a/config.yaml b/config.yaml index deae4d8..2353ca4 100644 --- a/config.yaml +++ b/config.yaml @@ -1,6 +1,20 @@ baseURL: https://albertogrespan.com disablePathToLower: true -languageCode: en-us +defaultContentLanguage: en +defaultContentLanguageInSubdir: false + +languages: + en: + locale: en-US + label: English + weight: 1 + title: Blog + es: + locale: es + label: Español + weight: 2 + title: Blog + title: Blog author: @@ -23,6 +37,11 @@ params: url: https://github.com/albertogg handle: albertogg +markup: + goldmark: + renderer: + unsafe: true + # Taxonomies activation default. taxonomies: tag: "tags" diff --git a/content/blog/2021-08-31-unifi-network--controller-in-a-raspberrypi.es.md b/content/blog/2021-08-31-unifi-network--controller-in-a-raspberrypi.es.md new file mode 100644 index 0000000..6d0f93e --- /dev/null +++ b/content/blog/2021-08-31-unifi-network--controller-in-a-raspberrypi.es.md @@ -0,0 +1,163 @@ +--- +date: 2021-08-31T22:52:50-04:00 +title: "Instalar UniFi Network Controller en una Raspberry Pi" +slug: "/instalar-unifi-network-controller-en-una-raspberry-pi/" +description: |- + Configuración de UniFi Network Controller en una Raspberry Pi con Raspberry Pi + OS. Configuración opcional de nginx usando certificados generados con mkcert. +translationKey: unifi-network-controller-raspberrypi +categories: + - Raspberry Pi +tags: + - UniFi + - OpenJDK + - nginx + - mkcert +toc: true +--- + +Instrucciones simples y directas para instalar UniFi Network Controller en una +Raspberry Pi. Solo lo he probado en Raspberry Pi OS, pero también debería +funcionar en Ubuntu. + +No voy a mostrar cómo instalar Raspberry Pi OS. Asumo que para este punto ya +tienes una instalación nueva del sistema operativo. Consulta el sitio oficial +para ver las [instrucciones de instalación][raspberry-pi-os] y cómo configurar +el [acceso remoto][remote-access] a la Raspberry Pi. + +## Cambiar el hostname + +Queremos asegurarnos de que la Raspberry Pi tenga el hostname correcto. En mi +caso tengo dnsmasq en mi red y accedo a los hosts por sus hostnames. Puedes leer +este post sobre [nombres de dominio para redes caseras][homenet-domain-name]. + + sudo hostnamectl set-hostname unifi-controller + +## Instalar OpenJDK versión 8 + +Por ahora necesitaremos OpenJDK versión 8. Parece que la versión 11 también +funciona, pero no la he probado. + + sudo apt install openjdk-8-jre + +## Instalar UniFi Network Controller + +Instala algunos requisitos adicionales de software. + + sudo apt update && sudo apt install ca-certificates apt-transport-https + +Agrega el [repositorio Debian para UniFi Network +Controller][install-unifi-via-apt]. + + echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list + +Instala el paquete. + + sudo apt install unifi -y + +En este punto el paquete `unifi` instaló todas sus dependencias y está listo +para usarse. + +### Iniciar UniFi Network Controller + +Ahora que todo está listo, necesitamos iniciar el servicio. + + sudo service unifi start + +Abre tu navegador y entra a `:8443`; verás +UniFi Network Controller. + +## Pasos adicionales + +Estos son pasos adicionales solo si quieres servir UniFi Network Controller +desde nginx. Los pasos adicionales incluyen: + +- Un certificado SSL. +- nginx y su configuración. + +**Nota:** los pasos adicionales solo funcionarán si tienes resolución DNS hacia +la dirección IP de la Raspberry Pi. + +### Certificado con mkcert + +Para el certificado usaremos mkcert. [mkcert][mkcert] es una herramienta simple +y sin configuración para crear certificados de desarrollo confiables localmente +con los nombres que quieras. + +En este punto asumimos que tienes `dnsmasq` o resolución DNS local que te +permite resolver `unifi-controller.home.arpa` hacia la dirección IP de la +Raspberry Pi. + +Genera el certificado. + + mkcert "unifi-controller.home.arpa" + +Con ese certificado listo, seguimos con la instalación de nginx. + +### Instalar nginx + +Ahora necesitamos nginx. Cualquier servidor reverse proxy funcionará. + + sudo apt install nginx + +### Configurar nginx + +Para la configuración queremos tener redirects personalizados de HTTP a HTTPS, +algunos proxy headers y nuestros certificados personalizados. + +Puedes copiar el certificado desde tu computadora local a la Raspberry Pi usando +SCP. + + scp ~/unifi-controller.home.arpa* pi@unifi-controller.home.arpa:/home/pi/ + +Ahora la parte de configuración. Crea el siguiente código en +`/etc/nginx/sites-avaliable/unifi` + + + server { + listen 80; + server_name unifi-controller.home.arpa; + + return 301 https://$server_name$request_uri; + } + + + server { + # SSL configuration + listen 443 ssl; + + server_name unifi-controller.home.arpa; + + ssl on; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_certificate /home/pi/unifi-controller.home.arpa.pem; + ssl_certificate_key /home/pi/unifi-controller.home.arpa-key.pem; + + location / { + proxy_pass https://localhost:8443; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_buffering off; + } + } + +Cuando lo tengas, enlázalo dentro de los sitios habilitados. + + sudo ln -s /etc/nginx/sites-available/unifi /etc/nginx/sites-enabled/unifi + +Reinicia nginx. + + sudo systemctl restart nginx + +Eso es todo. En este punto puedes abrir tu navegador y entrar a +`unifi-controller.local.arpa`; verás UniFi Network Controller. + +[raspberry-pi-os]: https://www.raspberrypi.org/software/ +[remote-access]: https://www.raspberrypi.org/documentation/computers/remote-access.html#remote-access +[homenet-domain-name]: https://www.ctrl.blog/entry/homenet-domain-name.html +[install-unifi-via-apt]: https://help.ui.com/hc/en-us/articles/220066768-UniFi-Network-How-to-Install-and-Update-via-APT-on-Debian-or-Ubuntu +[mkcert]: https://github.com/FiloSottile/mkcert diff --git a/content/blog/2021-08-31-unifi-network--controller-in-a-raspberrypi.md b/content/blog/2021-08-31-unifi-network--controller-in-a-raspberrypi.md index 151ff7b..c51fb3b 100644 --- a/content/blog/2021-08-31-unifi-network--controller-in-a-raspberrypi.md +++ b/content/blog/2021-08-31-unifi-network--controller-in-a-raspberrypi.md @@ -5,6 +5,7 @@ slug: "/unifi-network-controller-install-in-a-raspberry-pi/" description: |- Setting up the UniFi Network Controller in a Raspberry Pi running Raspberry Pi OS. Optional nginx configuration using certificates generated with mkcert. +translationKey: unifi-network-controller-raspberrypi categories: - Raspberry Pi tags: diff --git a/i18n/en.yaml b/i18n/en.yaml new file mode 100644 index 0000000..990372d --- /dev/null +++ b/i18n/en.yaml @@ -0,0 +1,16 @@ +about: + other: "About" +resume: + other: "Resume" +rss: + other: "RSS" +tableOfContents: + other: "Table of Contents" +by: + other: "By" +readInEnglish: + other: "Read in English" +readInSpanish: + other: "Read in Spanish" +license: + other: "This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License." diff --git a/i18n/es.yaml b/i18n/es.yaml new file mode 100644 index 0000000..b280b48 --- /dev/null +++ b/i18n/es.yaml @@ -0,0 +1,16 @@ +about: + other: "Acerca de" +resume: + other: "CV" +rss: + other: "RSS" +tableOfContents: + other: "Tabla de contenidos" +by: + other: "Por" +readInEnglish: + other: "Leer en inglés" +readInSpanish: + other: "Leer en español" +license: + other: "Esta obra está bajo una licencia Creative Commons Atribución-NoComercial-CompartirIgual 4.0 Internacional." diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index fcf9543..dda5a8a 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,5 +1,5 @@ - + @@ -13,6 +13,7 @@ {{ .Page.Title }} – {{ .Site.Params.Author }} + {{ partial "hreflang.html" . }} {{ $style := resources.Get "site/scss/style.scss" | css.Sass (dict "outputStyle" "compressed") }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index b035ecb..2cffdc6 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -4,7 +4,7 @@ {{- range .Site.RegularPages -}} {{- if eq .Type "blog" -}}
  • - {{ .Date.Format "January 2, 2006" }} {{ .Title }} + {{ partial "date.html" . }} {{ .Title }}
  • {{- end -}} {{- end -}} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index d92d225..8310d15 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -2,11 +2,12 @@

    {{ .Title }}

    -

    — {{ .Date.Format "January 2, 2006" }}

    +

    — {{ partial "date.html" . }}

    + {{ partial "language-switcher.html" . }} {{ if .Params.toc }}
    @@ -14,7 +15,7 @@

    Table of Contents

    {{ .Content }} diff --git a/layouts/partials/date.html b/layouts/partials/date.html new file mode 100644 index 0000000..5d7f29e --- /dev/null +++ b/layouts/partials/date.html @@ -0,0 +1,6 @@ +{{- if eq .Site.Language.Lang "es" -}} + {{- $months := dict "1" "enero" "2" "febrero" "3" "marzo" "4" "abril" "5" "mayo" "6" "junio" "7" "julio" "8" "agosto" "9" "septiembre" "10" "octubre" "11" "noviembre" "12" "diciembre" -}} + {{- printf "%d %s %d" .Date.Day (index $months (printf "%d" .Date.Month)) .Date.Year -}} +{{- else -}} + {{- .Date.Format "January 2, 2006" -}} +{{- end -}} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 2776f08..f4db19e 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,6 +1,6 @@ diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 0970246..9f44ca1 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,12 +1,12 @@ diff --git a/layouts/partials/hreflang.html b/layouts/partials/hreflang.html new file mode 100644 index 0000000..696be69 --- /dev/null +++ b/layouts/partials/hreflang.html @@ -0,0 +1,12 @@ +{{- range .AllTranslations -}} + +{{- end -}} +{{- $default := . -}} +{{- if ne .Language.Lang hugo.Sites.Default.Language.Lang -}} + {{- range .Translations -}} + {{- if eq .Language.Lang hugo.Sites.Default.Language.Lang -}} + {{- $default = . -}} + {{- end -}} + {{- end -}} +{{- end -}} + diff --git a/layouts/partials/language-switcher.html b/layouts/partials/language-switcher.html new file mode 100644 index 0000000..547a29b --- /dev/null +++ b/layouts/partials/language-switcher.html @@ -0,0 +1,8 @@ +{{- with .Translations -}} + +{{- end -}}