![]() |
![]() |
![]() |
Cockpit Guide | ![]() |
---|
Cockpit can be embedded in other projects.
None of the embedding APIs are completely stable at this time.
In addition, any APIs or behavior not explicitly documented here is an internal API and can be changed at any time.
Cockpit can be embedded into a larger web page as a frame. You can control some aspects of Cockpit via the URL. Here's an example:
<html> <head> <title>Embedded Cockpit</title> </head> <body> This is Cockpit. <br/> <iframe width="800px" height="600px" src="https://sunflower:9090/#server"/> </body> </html>
To confine Cockpit to a single machine, you can omit the "Hosts" element in the breadcrumb trail. The user then has no obvious way to navigate to a different machine.
To achieve this, use a URL like this:
https://server.example.com:9090/#server
When embedding Cockpit, it may be necessary to check whether Cockpit is available on a server before displaying the embedded Cockpit frame.
To do this perform a /ping
requset to Cockpit. This is a simple HTTP
GET request. It returns the following:
GET: https://server.example.com:9090/ping 200 OK: { "service": "cockpit" }
The /ping
request allows
Cross Origin Resource Sharing
headers and as such can be performed from Javascript code with any origin. The reqeust can also be
made via plain HTTP without SSL.
It is by design that no further information is present in the response.