<docker-compose.yml>
services:
  guacamole-db:
    image: mariadb:latest
    container_name: guac-db
    restart: always
    environment:
      MARIADB_ROOT_PASSWORD: root
      MARIADB_DATABASE: guacamole_db
      MARIADB_USER: guacamole_user
      MARIADB_PASSWORD: guacamole_password
    volumes:
      - ./initdb:/docker-entrypoint-initdb.d  # 초기 SQL 자동 실행
      - ./db:/var/lib/mysql
  guacd:
    image: guacamole/guacd
    container_name: guacd
    restart: always
  guacamole:
    image: guacamole/guacamole
    container_name: guacamole
    restart: always
    depends_on:
      - guacd
      - guacamole-db
    environment:
      GUACD_HOSTNAME: guacd
      MYSQL_HOSTNAME: guacamole-db
      MYSQL_DATABASE: guacamole_db
      MYSQL_USER: guacamole_user
      MYSQL_PASSWORD: guacamole_password
    ports:
      - "8080:8080"  # 웹 UI 접근 포트
    volumes:
      - ./custom-config/server.xml:/usr/local/tomcat/conf/server.xml
  nginx:
    image: nginx:latest
    container_name: guac-nginx
    restart: always
    ports:
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - guacamole
 
$ mkdir -p initdb
initdb 디렉토리 내 첨부된 2개 파일(001-create-schema.sql, 002-create-admin.sql) 넣고 docker compose up -d 실행
접속 정보 : admin // admin1234
$ mkdir custom-config
$ touch server.xml
<server.xml>
<Server port="8005" shutdown="SHUTDOWN">
  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="10000"
           maxKeepAliveRequests="100"
           keepAliveTimeout="5000"
           maxThreads="200"
           minSpareThreads="10"
           redirectPort="8443"
           URIEncoding="UTF-8" />
           #connectionTimeout="20000"
           #redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
      <Valve className="org.apache.catalina.valves.RemoteIpValve"
             remoteIpHeader="x-forwarded-for"
             remoteIpProxiesHeader="x-forwarded-by"
             protocolHeader="x-forwarded-proto" />
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true" />
    </Engine>
  </Service>
</Server>
 
<nginx.conf>
server {
    listen 80;
    server_name localhost;
keepalive_timeout 10;
    location /vdi/ {
        proxy_pass http://IP:8080/guacamole/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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_pass_header Authorization;
        proxy_pass_header Server;
        proxy_buffering off;
        proxy_redirect off;
        proxy_max_temp_file_size 0;
        client_max_body_size 0;
        proxy_read_timeout 1800;
        proxy_connect_timeout 1800;
        proxy_send_timeout 1800;
        proxy_request_buffering off;
    }
    location / {
        return 302 /vdi/;
    }
}
 
아래는 참고사항
# guacamole 컨테이너에서 SQL 스크립트 복사 및 DB 초기 스키마 생성
docker cp guacamole:/opt/guacamole/mysql/schema /home/guacamole/schema
docker exec -i guac-db mariadb -u root -proot guacamole_db < /home/mirdate/guacamole/001-create-schema.sql
 
# 접속URL http://IP:8080/guacamole/#/ 인것을 nginx로 재전달하여 http://IP:80 으로 접속하게 끔 하는 방법
# 접속 클라이언트 IP가 Log에 남지 않고 docker 컨테이터의 ip가 Log에 기록되기 때문에
custom-config/server.xml로 guacamole 내 tomcat에 파일 교체 연결처리
