Hi
i have problem with ticket and cookie system
i got 401 error i think this happend because i used spicial port 4000 but i dont know how fix it
i have problem with ticket and cookie system
Code:
<?php
/*
For the first you need:
1. Create User group "VNC" –> Datacenter / Permissions / Group
2. Create new user -> Datacenter / Permissions / Users - select Group: "VNC", Realm: pve
3. Create new Role -> Datacenter / Permissions / Roles - select Name: "VNC", Privilegies: VM.Console (only)
3. Add permision to access VM -> Datacenter / Node / VM / Permissions / Add Group Permissions - select Group: "VNC", Role: "VNC"
*/
require_once 'vendor/autoload.php';
use ProxmoxVE\Proxmox;
$host = 'X.x.x.x';
$node = 'node';
$vmid = '102';
$credentials = [
'hostname' => $host,
'username' => 'root',
'password' => 'XXXX'
];
$proxmox = new Proxmox($credentials);
if($login = $proxmox->login()) {
// Get and save ticket
$ticket = $login->getTicket();
$config = $proxmox->create('/nodes/'.$node.'/qemu/'.$vmid.'/vncproxy', [
'websocket' => 1 // Start websocket
]);
$websock = $proxmox->get('/nodes/'.$node.'/qemu/'.$vmid.'/vncwebsocket', [
'vncticket' => $ticket,
'port' => $config['data']['port'],
]);
// Set Cookies (domain must be in same space that pve. Example: pve – pve1.your.com, host – auth.your.com, Set cookies to your.com)
setcookie('PVEAuthCookie', $ticket , 0, '/', 'localhost:4000', false);
$src_href = 'https://'.$host.':8006/?console=kvm&novnc=1&node='.$node.'&resize=1&vmid='.$vmid.'&path=api2/json/nodes/'.$node.'/qemu/'.$vmid.'/vncwebsocket/port/'.$config['data']['port'].'/vncticket/'.$ticket;
echo '<iframe src="'.$src_href.'" frameborder="0" scrolling="no" width="800px" height="600px"></iframe>';
}
?>
i got 401 error i think this happend because i used spicial port 4000 but i dont know how fix it