Accessing VM's NoVNC from another website

MicJB

New Member
Feb 27, 2015
12
0
1
London
Hi all,
I'm working on a minimalistic service to let users create and manage their own OpenVZ VMs and access their VM terminal through my website.

My original plan was to simply embed in an iframe (in my website) the VM's NoVNC console url, ex:

HTML:
<iframe src="https://<proxmox-server-iport>/?console=openvz&novnc=1&vmid=123&vmname=hostname&node=proxmox">...

However this doesn't work because I need to pass a cookie containing the access-ticket (which I can get via the API) to my proxmox server in order to access such page. The problem is that I can't set cookies to my proxmox server from my website server (they live on separate machines), this is a general rule with cookies.

Question:

Is there an API or page on my proxmox server that I can call/create to set the access-ticket cookie? For example I could create a php page in my proxmox server that receives a POST request containing the ticket and set it as a cookie. Is there already such a page somewhere? If not, can anyone point me on how I would go about creating one?

Alternatively, (since I create a proxmox user for every user in my website) is there a way to programmatically log in a proxmox user via API? This way I'm prettey sure the user would have the ticket correctly set to access the VM console URL.

If there is any other method I didn't think of to setup VM console access from another website which is not the proxmox server please let me know.

Thank you!
Mic
 
Last edited:
Hello,
you can create an access ticket via the API.
Please take a look on the following page: http://pve.proxmox.com/wiki/Proxmox_VE_API

Methods you need:
POST /api2/json/access/ticket
POST /api2/json/nodes/{node}/openvz/{vmid}/vncproxy
GET /api2/json/nodes/{node}/openvz/{vmid}/vncwebsocket

Best regards
Phinitris
 
Hello,
you can create an access ticket via the API.
Please take a look on the following page: http://pve.proxmox.com/wiki/Proxmox_VE_API

Methods you need:
POST /api2/json/access/ticket
POST /api2/json/nodes/{node}/openvz/{vmid}/vncproxy
GET /api2/json/nodes/{node}/openvz/{vmid}/vncwebsocket

Hi Phinitris, thanks for your reply. I do know that I can get a ticket from the API and that's what I do actually. The problem is that I cannot use the ticket because it needs to be passed as a cookie to the proxmox server and there is no way I (or anyone) can set a cookie to the proxmox server from another server (my website). In general website A cannot set a cookie for website B, which is what I'd need to do in this case.
Unless... the proxmox server had a special api or page that accepts a POST request with the ticket and sets it as a cookie - that's because setting a cookie for a website can only be done by that very website, not others.

As for the vncproxy/vncwebsocket APIs I'm not sure what I'm supposed to do with them or how they would be useful, any example?

This is the pseudo code I'm using but that's not working because of the cookie issue:

http:/mywebsite.com/viewconsole.php?vmid=100:
PHP:
require_once "Proxmox.php";

$vmid = $_GET[vimd];

$p = new Proxmox();

// get ticket for user
$ticket = $p->post('/api2/json/access/ticket');

// redirect to proxmox console URL
header('Location: http://my-proxmox-server.com?console=openvz&novnc=1&vmid=$vmid&vmname=hostname&node=proxmox');

setcookie('PVEAuthCookie', $ticket); // <-- this does not work because at this point I'm still at mywebsite.com not my-proxmox-server.com!
 
Hey,
I would recommend creating an access ticket via PHP and the vnc ticket also via PHP.
Then you can access the (No)VNC Console without any authentication required.
I'm not available until Sunday evening. If you still need help, I can send you my Skype nick and I'll assist you.

Best regards
Phinitris


Sent from my iPad using Tapatalk
 
  • Like
Reactions: hfzrmd
Phinitirs, please send me your Skype nick, thanks for your help, so far looks like the only three options available are 1) to modify proxmox api to programmatically log in the user which automatically sets the authorization cookie, or 2) modify proxmox api to POST the authorization cookie and this way set it from the server's domain or 3) abandon Proxmox and use something else...
 
Hey,
that's not necessary. Proxmox supports that out of the box.

Skype: henne.s

Best regards
Henry
 
Hi!

I need the same solution. I'd like to embed the vnc console to my own site.
I can get the vnc ticket with the POST /api2/json/nodes/{node}/openvz/{vmid}/vncproxy API call.
After it I call the GET /api2/json/nodes/{node}/openvz/{vmid}/vncwebsocket endpoint and it returns a port.
After it I try to access the websocket with
wss://<IP>:8006/api2/json/nodes/bg01/qemu/<vmid>/vncwebsocket?port=<port>&vncticket=<vncticket>

But it seem to me that is need the PVEAuthCookie also, which means that I need a valid login for the proxmox UI also. I tought the I can access the VNC console withouth login to the proxmox UI. Am I wrong?
 
Hi!

I need the same solution. I'd like to embed the vnc console to my own site.
I can get the vnc ticket with the POST /api2/json/nodes/{node}/openvz/{vmid}/vncproxy API call.
After it I call the GET /api2/json/nodes/{node}/openvz/{vmid}/vncwebsocket endpoint and it returns a port.
After it I try to access the websocket with
wss://<IP>:8006/api2/json/nodes/bg01/qemu/<vmid>/vncwebsocket?port=<port>&vncticket=<vncticket>

But it seem to me that is need the PVEAuthCookie also, which means that I need a valid login for the proxmox UI also. I tought the I can access the VNC console withouth login to the proxmox UI. Am I wrong?
Hi Daniel,

Did you manage the solve your problems? I am looking for a similar solution as well. I need to embed this in the website and redirect the user to login to their own VM.

Appreciate if you could share if you have found the solutions

Thanks
MC
 
Hi guys, have you someone solved this issue somehow?

I'm struggling with the same problem, I can get a ticket and then a vncticket, but Proxmox kicks me with error 1006...
 

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!