[SOLVED] noVNC integration problem (Error 401: No ticket)

Sephy

Member
Aug 9, 2021
3
1
8
24
Hi,

i started today to integrate Proxmox in our web php application and everything works great except noVNC.

I'm using this api wrapper: https://github.com/Saleh7/ProxmoxVE_PHP_API
Additionally i oriented myself and used some code from: https://github.com/CpuID/pve2-api-php-client

My Problem is that i always get the no ticket error, but the PVEAuthCookie is set.
I already tried to research the problem and found some posts about it but nothing of the solutions work.

See the relevant code snippets attached:
PHP:
$vnc = new ProxmoxVNC(); # login(), check_login_ticket(), setCookie() from pve2_api.class.php
if ($vnc->login())
$vnc->setCookie();

new Proxmox; # initializes my proxmox object, constructor calls Request::Login($credentials);
$nodes = new Nodes;
$proxy = $nodes->createQemuVncproxy('alpha', 106); # alpha is the name of my host, 106 the vm id
$nodes->qemuVncwebsocket('alpha', 106, $proxy->data->port, $proxy->data->ticket);
$vnc_iframe = $vnc->getFrame(106, $proxy->data->port, $proxy->data->ticket);

PHP:
    public function getFrame($vmid, $port, $ticket)
    {
        #both variants fail with the same mentioned error:
        #return "<iframe style='width: 900px; height: 900px;' src='https://{$this->hostname}:8006/?console=kvm&novnc=1&node=alpha&resize=scale&vmid={$vmid}&path=api2/json/nodes/alpha/qemu/{$vmid}/vncwebsocket?port={$port}&vncticket={$ticket}'></iframe>";
        #return "<iframe style='width: 900px; height: 900px;' src='https://{$this->hostname}:{$this->port}/?console=kvm&novnc=1&vmid={$vmid}&node=alpha&resize=off&cmd=' frameborder='0' scrolling='no'></iframe>";
    }

And as I said, everything works fine, i get all results from the api. I also tried to login with the account on the proxmox webinterface and copied the value of the cookie from there and pasted it on my website, but still the same error. I'm also using the same domain (just different subdomain for proxmox host and website).

cookie.PNG

Oh and i just saw that i also get an error in the proxmox webinterface:
error.PNG

(The test user should have all permissions. PVEVMUser)

Maybe somebody here got an idea and can help me out here?
Excited to here from you!
 
Last edited:
I'm an idiot, solved the issue myself. I didn't called the website with https://.
 
Hi, I'm back with a new problem, but this time i also got the solution, so I just want to mention it for people who may get into the same.
So today I realized that i still get the "Error 401: no ticket" when im not additional also have the PVEAuthCookie set for the proxmox url.

The solution:
Code:
setcookie("PVEAuthCookie", $this->login_ticket['ticket'], 0, "/", '.mydomain.com');
So i added '.mydomain.com' at the end of the setcookie function. Now all subdomains can access that cookie.

My website is reachable at https://app.mydomain.com and the proxmox webinterface at https://alpha.mydomain.com:8006
My iFrame looks like this:

Code:
return "<iframe style='width: 960px; height: 640px;' src='https://{$this->hostname}:{$this->port}/?console=kvm&novnc=1&vmid={$this->vm_id}&node=alpha&resize=off&cmd=' frameborder='0' scrolling='no'></iframe>";

I hope this may help people who get stuck at the same. Have a nice day. ✌️
 
  • Like
Reactions: jims888

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!