Skip to content

guacamole+guacd+mysql实现远程vnc

Tags:

建立新域名 vnc.xxx.com

反向代理要这么填

location / {
        proxy_pass          http://127.0.0.1:9040/guacamole/;
        proxy_cookie_path   /guacamole/ /;
        proxy_buffering     off;
        proxy_http_version  1.1;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    Upgrade $http_upgrade;
        proxy_set_header    Connection $http_connection;
        access_log          off;
}
    

准备mysql docker

mkdir -p /data/guacamole/mysql
GUACA_PWD='__Your_Own_Password__'
# docker stop guaca-mysql && docker rm guaca-mysql
docker run --name guaca-mysql \
  --restart=always \
  -e PUID=$UID -e PGID=$GID -e TZ=Asia/Shanghai \
  -e MYSQL_ROOT_PASSWORD=${GUACA_PWD} \
  -e MYSQL_DATABASE='guaca' \
  -e MYSQL_USER='guaca' \
  -e MYSQL_PASSWORD=${GUACA_PWD} \
  -p 9041:3306 \
  -v /data/guacamole/mysql:/var/lib/mysql \
  -d mysql/mysql-server
docker logs guaca-mysql

init db

docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --mysql > /data/guacamole/mysql/initdb.sql
# 进入mysql docker
docker exec -it guaca-mysql bash
# now inside
mysql -u -p # 输入之前的GUACA_PWD对应的密码值
GRANT SELECT,INSERT,UPDATE,DELETE ON guaca.* TO 'guaca'@'%';
FLUSH PRIVILEGES;
# init db
cat /var/lib/mysql/initdb.sql | mysql -u root -p guaca

开启guacd && guacamole

docker run --name guacd --restart=always  -d guacamole/guacd
docker run --name guaca --restart=always  --link guacd:guacd --link guaca-mysql:mysql \
  -e PUID=$UID -e PGID=$GID -e TZ=Asia/Shanghai \
  -e MYSQL_DATABASE='guaca' \
  -e MYSQL_USER='guaca' \
  -e MYSQL_PASSWORD=${GUACA_PWD}  \
  -d -p 9040:8080 guacamole/guacamole
docker logs -f guaca
# docker stop guca && docker rm guca

访问 vnc.xxx.com

并设置连接

回到主页 – 尽可能点击连接进行登录了。

Leave a Reply

Your email address will not be published.