Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Last active January 10, 2025 04:31
Show Gist options
  • Save diegofcornejo/5e563e53cd5f628e1f93e3b9925ad064 to your computer and use it in GitHub Desktop.
Save diegofcornejo/5e563e53cd5f628e1f93e3b9925ad064 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: guacamole_db
POSTGRES_USER: guacamole_user
POSTGRES_PASSWORD: yourSecurePassword
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:
POSTGRES_DATABASE: guacamole_db
POSTGRES_USER: guacamole_user
POSTGRES_PASSWORD: yourSecurePassword
POSTGRES_HOSTNAME: postgres
POSTGRES_PORT: 5432
GUACD_HOSTNAME: guacd
GUACD_PORT: 4822
#TOTP_ENABLED: 'true' # Enable TOTP authentication
depends_on:
- postgres
- guacd
ports:
- "127.0.0.1:4880:8080"
networks:
- guacamole-network
volumes:
- ./record:/record:rw
restart: always
networks:
guacamole-network:
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