Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Last active August 16, 2025 04:06
Show Gist options
  • Save diegofcornejo/403a1d86fa288f1955525d7913033771 to your computer and use it in GitHub Desktop.
Save diegofcornejo/403a1d86fa288f1955525d7913033771 to your computer and use it in GitHub Desktop.
Install Apache Guacamole (PostgreSQL) with docker compose

Install Apache Guacamole (PostgreSQL) with docker compose

Copy the docker compose file to the server

Get the database script for postgres

docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgresql > initdb.sql

Init the database (just the database)

docker compose up -d postgres
docker logs -f guacamole-postgres
# Wait for the database to be ready
# You should see the following message: "database system is ready to accept connections" or something similar

Import the database script

docker exec -i guacamole-postgres psql -U guacamole_user -d guacamole_db < initdb.sql

Start the rest of the services

docker compose up -d

Access the guacamole client

http://127.0.0.1:4880/guacamole

Note

In this example the guacamole client is exposed on port 4880 just for 127.0.0.1 (localhost) because the guacamole-client is exposed to the public internet with nginx.

Tip

For an example of how setup nginx to expose the guacamole client see the file nginx.guacamole.conf in this repository.

Tip

The easy way to setup SSL/TLS is to use certbot with nginx.

services:
postgres:
image: postgres:alpine
container_name: guacamole-postgres
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- ./data:/var/lib/postgresql/data
networks:
- guacamole-network
restart: always
guacd:
image: guacamole/guacd
container_name: guacamole-guacd
networks:
- guacamole-network
restart: always
volumes:
- ./drive:/drive:rw
- ./record:/record:rw
guacamole:
image: guacamole/guacamole
container_name: guacamole-client
environment:
# GUACD
GUACD_HOSTNAME: guacd
GUACD_PORT: 4822
# PostgreSQL
POSTGRESQL_HOSTNAME: postgres
POSTGRESQL_PORT: 5432
POSTGRESQL_DATABASE: ${DB_NAME}
POSTGRESQL_USERNAME: ${DB_USER}
POSTGRESQL_PASSWORD: ${DB_PASSWORD}
# Opcional
TOTP_ENABLED: "true"
depends_on:
- postgres
- guacd
ports:
- "127.0.0.1:4880:8080"
networks:
- guacamole-network
volumes:
- ./record:/record:rw
restart: always
networks:
guacamole-network:
DB_NAME=guacamole_db
DB_USER=guacamole_user
DB_PASSWORD=CHANGE_ME_STRONG
server {
server_name guacamole.diegocornejo.com;
listen 80;
location / {
proxy_pass http://127.0.0.1:4080/guacamole/;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_redirect off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment