安裝 Guacamole 1.6.0 使用ubuntu+docker+postgresql
使用 Docker 安裝酪梨醬 Guacamole
安裝環境:
- Ubuntu 24.04
- Docker 28.1.1
- Guacamole 1.6.0-RC1
- 日期:2025/05/18
參考官方文件:Guacamole Docker
本文件安裝三個容器
- PostgreSQL 資料庫
- guacamole/guacd
- guacamole/guacamole
⚠️ 注意事項:以下步驟請務必注意 IP、Port、以及容器名稱,請記得調整。
步驟說明
1. 安裝並啟用 guacd
docker run --restart always --name guacd -d -p 4822:4822 guacamole/guacd:1.6.0-RC1
2. 安裝 PostgreSQL 資料庫伺服器,並建立 Guacamole 資料庫
docker run -d --restart=always --name postgres-17 -p 5432:5432 \
-e POSTGRES_USER=root \
-e POSTGRES_PASSWORD=密碼 \
-v postgres-17-data:/var/lib/postgresql/data postgres:17.4-bookworm
進入容器:
docker exec -it postgres-17 bash
進入 PostgreSQL 服務器:
psql -U root -p 5432 -h localhost -W
建立資料庫:
create database guacamole;
3. 產生資料庫 schema 並匯入 PostgreSQL
docker run --rm guacamole/guacamole:1.6.0-RC1 /opt/guacamole/bin/initdb.sh --postgresql > initdb.sql
apt-get install -y postgresql-client
psql -U root -p 5432 -h <容器IP> -W -d guacamole < initdb.sql
4. 安裝 guacamole 主應用
docker run --restart always --name guacamole \
-e GUACD_HOSTNAME=<guacd ip> \
-e GUACD_PORT=4822 \
-e POSTGRESQL_HOSTNAME=<postgres ip> \
-e POSTGRESQL_PORT=5432 \
-e POSTGRESQL_DATABASE=guacamole \
-e POSTGRESQL_USERNAME=root \
-e POSTGRESQL_PASSWORD=密碼 \
-d -p 8080:8080 guacamole/guacamole:1.6.0-RC1
5. nginx 反向代理設定
location /guacamole/ {
proxy_pass http://ip:8081;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
client_max_body_size 1g;
#proxy_cookie_path /guacamole/ /new-path/; 若位置不一樣
access_log off;
}