VNC WebSocket 연결 문제 - 브라우저 보안 정책으로 인한 미해결 상태

WebSocket 1006 오류로 인해 브라우저에서 VNC 연결 실패
- 서버 환경에서는 연결 가능하나 브라우저 보안 정책으로 차단
- 역방향 프록시 솔루션 문서화 완료
- 추후 nginx 프록시 구현 필요

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-12 01:44:47 +09:00
parent 1dc09101cc
commit ac620a0e15
5 changed files with 713 additions and 22 deletions

View File

@@ -106,26 +106,46 @@ class ProxmoxClient:
def get_vnc_ticket(self, node: str, vmid: int) -> Optional[Dict]:
"""VNC 접속 티켓 생성"""
try:
# 먼저 VM 상태 확인
vm_status = self.get_vm_status(node, vmid)
print(f"🔍 VM {vmid} 상태: {vm_status}")
if vm_status.get('status') != 'running':
print(f"❌ VM {vmid}이 실행중이 아닙니다. 현재 상태: {vm_status.get('status', 'unknown')}")
return None
data = {
'websocket': '1',
'generate-password': '1' # 패스워드 생성 활성화
}
print(f"🔄 VNC 티켓 요청: {self.base_url}/nodes/{node}/qemu/{vmid}/vncproxy")
response = self.session.post(
f"{self.base_url}/nodes/{node}/qemu/{vmid}/vncproxy",
data=data,
timeout=10
)
print(f"📡 VNC 티켓 응답 상태: {response.status_code}")
print(f"📄 VNC 티켓 응답 내용: {response.text}")
if response.status_code == 200:
vnc_data = response.json()['data']
print(f"✅ VNC 티켓 생성 성공: {vnc_data}")
# WebSocket URL 생성
# WebSocket URL 생성 (인증 토큰 포함)
encoded_ticket = quote_plus(vnc_data['ticket'])
vnc_data['websocket_url'] = f"wss://{self.host}:443/api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket?port={vnc_data['port']}&vncticket={encoded_ticket}"
# Proxmox 세션 쿠키도 함께 포함 (CSRFPreventionToken도 필요할 수 있음)
csrf_token = getattr(self, 'csrf_token', None)
if csrf_token:
vnc_data['websocket_url'] = f"wss://{self.host}:443/api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket?port={vnc_data['port']}&vncticket={encoded_ticket}&CSRFPreventionToken={csrf_token}"
else:
vnc_data['websocket_url'] = f"wss://{self.host}:443/api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket?port={vnc_data['port']}&vncticket={encoded_ticket}"
# 디버깅 정보 추가
print(f"🔗 WebSocket URL: {vnc_data['websocket_url']}")
print(f"🔑 VNC Password: {vnc_data.get('password', 'N/A')}")
return vnc_data
else:
print(f"❌ VNC 티켓 생성 HTTP 오류: {response.status_code}")