HowTo Self Host Postiz on Ubuntu (on Proxmox VE)

This document provides a comprehensive guide to self-hosting Postiz, an open-source platform for managing your social media presence. It covers installation on various configurations and clarifies technical details. You can also refer to the YouTube video titled Self Hosted Postiz Setup Guide (HowTo).

What is Postiz?

Postiz helps you to automate social media posting, gather valuable analytics, and leverage effective tools for promoting your content across different platforms.

A browser is required to interact with Postiz.

Postiz can be self-hosted or consumed as an online service via subscription. We’re exploring the self-hosting option in this article.

Self-Hosting Options

Self-Host (Single Computer): This setup involves a dedicated computer running Postiz. You log into this computer to manage your social media posts. Installing Postiz on Ubuntu Desktop is ideal, as it provides a GUI and productivity tools beneficial for social media management.

Self-Host (Local LAN): In this setup, a server on your network hosts the Postiz solution. Other computers on the same network can access Postiz through a web browser. While both Ubuntu Desktop and Server versions are compatible, the Server version is recommended due to its lower resource requirements.

This guide covers this option and will install the Server as a VM on Proxmox.

Self-Host (Public): This option is similar to Local LAN, but with a registered domain name, allowing access from any internet-connected device. The key difference lies in configuring your router (firewall and routing adjustments) to handle HTTPS traffic directed to port 5000 of the Postiz server.

Self-Host Enterprise: This setup caters to large-scale operations with multiple users and high traffic volume. In this case, the various Docker containers that make up Postiz are installed on separate machines rather than on a single computer. (Not covered in this guide)

Ubuntu Desktop

This guide is based on Ubuntu Server but will work on Ubuntu Desktop. Rather than using the GUI tools you will use the Terminal.

Proxmox

We're installing Postix on a Proxmox VM. In this article I cover the bare minimum but have a series on this open-source product titled Proxmox-NUT Homelab HOWTO : Step 0 : The Proxmox-NUT HomeLab HowTo: Introduction.

If you are not interested in installing Postiz on Proxmox, just skip the two sections dedicated to Proxmox. No other changes are necessary.



YAML files

This HowTo edits YAML files (extension yaml or yml). Whitespace is part of YAML's formatting and must be observed, otherwise you will get errors.

1. Creating the Proxmox VM

Download Ubuntu ISO from Get Ubuntu | Download | Ubuntu and make it available within Postiz.

From the Proxmox dashboard, create a new VM named vm-postiz. Use the Ubuntu Server ISO for installation. Set the hard disk to 50G, allocate 4 CPU cores (2 sockets with 2 cores each), and 8G of RAM.

A hard disk size of 50G will leave around 11G of free disk space when installing the server version. Increase this if you are installing Ubuntu Desktop of have large social media campaigns.

On the Server versions you can get away with 2 rather than 4 cores but may experience sluggishness. On the Desktop version 4 cores is the minimum.

4GB is the recommended minimum to operate Postiz although 8GB is operationally better.

When the VM is Started for the first time, it boots on the ISO from where you will start the Ubuntu Server installation.

2. Install Ubuntu

(If you are installing on bare-metal use a tool such as Rufus to make the ISO bootable from USB)

From the boot screen, select “Try or Install Ubuntu Server”. Skip updating the installer, installing OpenSSH, or joining Ubuntu Pro during installation (they will be discussed separately).

You should replace credentials / machine name with your own.

Once the installation completes you need to reboot the server. Press Enter to "remove" the installation ISO.

Updates

Log into the Ubuntu server and update package lists and versions. You need elevated privileges (sudo)

sudo apt update
sudo apt upgrade

Install OpenSSH

OpenSSH is an open-source implementation of the SSH protocol. It allows remote server login. You can skip this step if you don't need to access the server from another computer. Install it with:

sudo apt install openssh-server

To connect to the server you need to know its IP address.

ipaddr show

After installing the OpenSSH server you can install a tool such as Putty to access the server. The first time you will be asked to accept the host keys. This is for security purposes. Since we trust this machine will accept it.

Reboot Ubuntu

If you need to reboot the server enter:

sudo reboot now

Subscribe and apply Ubuntu Pro

Ubuntu Pro provides stability, security, and compliance automated updates and longer maintenance windows together with other benefits. Ubuntu provides 5 free licences to individual users.

Subscribe at https://ubuntu.com/pro. To associate your key with the computer do the following:

sudo pro attach <paste your key>

Install QEMU on your the Proxmox Postiz VM

QEMU is a free and open-source emulator that emulates the processor of a computer. It helps improve monitoring, enhance performance, and execute commands on the guest system by enabling communication between the Proxmox VE host and the virtual machine.

To install the guest agent, use the following command:

sudo apt install qemu-guest-agent

Once the installation is complete, shut down the VM. From the Proxmox Dashboard, select the VM, go to the Options tab, double-click on the QEMU Guest Agent, and enable the function from the dialog box that appears.

After the VM starts, verify that the QEMU guest agent is running by checking the service status:

systemctl status qemu-guest-agent

Install / Configure Docker

The diagram above illustrates the Postiz solution, which consists of various components, each running within its own Docker container (except Caddy). Docker Compose is the tool used for defining and running the applications. This step will guide you through installing Docker Compose, based on the instructions from Docker’s documentation.

First, set up Docker's APT repository:

# Add Docker's official GPG key:
sudo apt-getupdate
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
 "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
 $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
 sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-getupdate

Next, install Docker:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

To test the Docker installation:

sudo docker run hello-world

If you invoke the hello-world script without elevated privileges you will get an error. This is because non-root users do not have the right to run Docker.

Grant Non-root User Rights to Manage and Run Docker

  1. Create the docker group (it should already exist):
sudo groupadd docker
  1. Add current user to the docker group:
sudo usermod -aG docker $USER
  1. Activate the new group:
newgrp docker
  1. Verify that Docker can be run without elevated access:
docker run hello-world

You should get the output described above.

Install / Configure Postiz

With Docker installed and operational, installing the components that make up Postiz involves executing a YAML file that will create all the containers constituting Postiz. The source YAML file and instructions are available from the Postiz Documentation page .

In this HowTo, the URL for the Postiz server will be https://postiz.homenet.lan. Adjust accordingly if your URL differs.

  1. Create a directory (we're calling it postiz) and change to it:
mkdir postiz
cd postiz
  1. Copy the YAML file from Postiz Installation Guide into a text editor and save it as docker-compose.yml.

  2. Modify 4 lines (Lines 8 - 11) :

services:
 postiz:
 image: ghcr.io/gitroomhq/postiz-app:latest
 container_name: postiz
 restart: always
 environment:
 # You must change these. Replace `postiz.your-server.com` with your DNS name - what your web browser sees.
 MAIN_URL:"https://postiz.your-server.com"# Line 8
 FRONTEND_URL:"https://postiz.your-server.com"# Line 9
 NEXT_PUBLIC_BACKEND_URL:"https://postiz.your-server.com/api"# Line 10
 JWT_SECRET:"random string that is unique to every install - just type random characters here!"# Line 11
 # These defaults are probably fine, but if you change your user/password, update it in the
 # postiz-postgres or postiz-redis services below.
 DATABASE_URL:"postgresql://postiz-user:postiz-password@postiz-postgres:5432/postiz-db-local"
 REDIS_URL:"redis://postiz-redis:6379"
 BACKEND_INTERNAL_URL:"http://localhost:3000"
 IS_GENERAL:"true"# Required for self-hosting.
 # The container images are pre-configured to use /uploads for file storage.
 # You probably should not change this unless you have a really good reason!
 STORAGE_PROVIDER:"local"
 UPLOAD_DIRECTORY:"/uploads"
 NEXT_PUBLIC_UPLOAD_DIRECTORY:"/uploads"
 volumes:
 - postiz-config:/config/
 - postiz-uploads:/uploads/
 ports:
 -5000:5000
 networks:
 - postiz-network
 depends_on:
 postiz-postgres:
 condition: service_healthy
 postiz-redis:
 condition: service_healthy
 postiz-postgres:
 image: postgres:17-alpine
 container_name: postiz-postgres
 restart: always
 environment:
 POSTGRES_PASSWORD: postiz-password
 POSTGRES_USER: postiz-user
 POSTGRES_DB: postiz-db-local
 volumes:
 - postgres-volume:/var/lib/postgresql/data
 networks:
 - postiz-network
 healthcheck:
 test: pg_isready -U postiz-user -d postiz-db-local
 interval:10s
 timeout:3s
 retries:3
 postiz-redis:
 image: redis:7.2
 container_name: postiz-redis
 restart: always
 healthcheck:
 test: redis-cli ping
 interval:10s
 timeout:3s
 retries:3
 volumes:
 - postiz-redis-data:/data
 networks:
 - postiz-network
volumes:
 postgres-volume:
 external:false
 postiz-redis-data:
 external:false
 postiz-config:
 external:false
 postiz-uploads:
 external:false
networks:
 postiz-network:
 external:false
  1. Process the YAML file:
docker compose up

The installation completes when the various components report that they have entered a running state.

If you need to reprocess the YAML file:

docker compose down
docker compose up

Install / Configure Caddy

The commands to install and configure Caddy were sourced from Caddy's documentation.

Caddy acts as a reverse proxy, handling requests to https://postiz.homenet.lan and routing them to port 5000 of the Postiz server. Caddy will use its internal CA for HTTPS.

Set up Caddy's APT repo and install it:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

With elevated privileges, edit the file /etc/caddy/Caddyfile:

sudo nano /etc/caddy/Caddyfile

Replace the contents with the following (adjust if your URL is not postiz.homenet.lan) and save it:

postiz.homenet.lan {
 reverse_proxy * localhost:5000
 tls internal
}

Create the Caddy Service

Next, create the service that will invoke Caddy, ensuring it starts whenever the server reboots. Edit the file (with elevated privileges) /etc/systemd/system/caddy.service and paste the following:

# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

The service references the caddy file we created before.

To verify that the caddy service is active, type in systemctl status caddy:

Routing postiz.homenet.lan to the Postiz server

The final stage of this HowTo deals with translating the URL into the machine's IP address.

Running Postiz from a Single Computer

If you will be running Postiz from a single computer (e.g., you installed Ubuntu Desktop), you need to edit the /etc/hosts file with elevated privileges. Add 127.0.2.1 postiz.homenet.lan to this file and save it.

To verify everything is set up correctly, type ping postiz.homenet.lan and you should receive a response.

Accessing Postiz from Other Computers on the LAN

If you installed a server version of Ubuntu (as described in this HowTo), you need to:

  • Fix the IP address so that it never changes.
  • Adjust the other computers on the LAN to resolve the URL to the Postiz server' IP.

Fixing the Server's IP Address

The IP address of the Postiz server is dynamic, meaning it can change. If the IP address changes, other computers on the LAN will not be able to reference it. Fixing the IP address ensures it remains constant. We will explore two methods to achieve this:

  • Hard code the IP address.
  • Fix the IP address using a DHCP Static entry in your router.
Hard Coding the IP Address

Use ip addr show to list networking information and note the network adapter name.

Then, list the contents of the directory /etc/netplan/ and edit the YAML file contained within (with elevated privileges).

Replace the contents of the file with a comfiguration similar to the one listed here. Note: This file will need to be modified for your network. Refer to this document for guidance.

#network:
 version:2
 renderer: networkd
 ethernets:
 ens18:# this line can be different in your case
 dhcp4:no
 addresses:
 -192.168.16.7/24# this line can be different in your case
 routes:
 - to: default
 via:192.168.16.1# this line can be different in your case
 nameservers:
 addresses: [192.168.16.1] # this line can be different in your case
Fixing the IP Address Using a DHCP Static Entry

Many routers allow you to associate the MAC address of a device (the Postiz server in this case) with a fixed IP address. The MAC address can be found using ip addr show. This is known as a DHCP Static entry.

Adjusting Other Computers on the LAN

After fixing the Postiz server's IP address, other computers on the LAN need to resolve the URL postiz.homenet.lan to the IP address (e.g., 192.168.16.7).

We will consider two methods:

  • Modify the host files of each computer on the LAN.
  • Create a Static DNS entry.
Modifying Host Files

We already discussed how to adjust the /etc/hosts file in Ubuntu.

In Windows you need to edit the file (with administrative privileges) %WINDIR%/System32/drivers/etc/hosts using a text editor.

Modifying individual host files is quite laborious, involving changing the hosts file of every computer that will need to access the Postiz server.

Creating a Static DNS Entry

If your router supports this function (as shown in the example from a Mikrotik router), you can add a Static DNS entry. This approach requires changing the configuration in only one place.

Test the solution

From a command prompt or your router or a command terminal on the client computers, ping the Postiz server and you should get a reply.

Logging into the Postiz Server

The first time you log into the Postiz Server at https://postiz.homenet.lan, you will be prompted to accept the self-signed certificate. Once accepted, the Postiz interface will appear.

Setting up the social media connections will be covered in other HowTos.


 

Follow This, That and (Maybe), the Other:

 

Comments

Popular posts from this blog

20150628 Giarratana Circular

HOWTO setup OpenVPN server and client configuration files using EasyRSA

How to clone and synchronise a GitHub repository on Android