Monitoring endpoint

Monitoring endpoint is an API endpoint which allows the user to manage the tunnelize server. It exposes a JSON API for managing tunnels, clients, links and monitoring system.

To setup a monitoring API configure endpoints like this:

{
    "server":{
        // ...other fields
        "endpoints":{
            "monitoring-endpoint": {
                "type": "monitoring",
                "port": 3000,
                "encryption": {
                    "type": "none"
                },
                "address": null,
                "authentication": {
                    "type": "basic",
                    "username": "admin",
                    "password": "changethispassword"
                },
                "allow_cors_origins": {
                    "type": "any"
                }
            }
        }
    }
    
}

Fields:

KeyDescriptionDefault Value
typeType of service. Always monitoring for monitoring endpoint.No default
portPort numberNo default
encryptionEncryption for HTTPS access. See configuring encryption.No encryption
addressService address.0.0.0.0
authenticationType of authentication. See configuring authentication below.No default
allow_cors_originsCORS origins allowed. See configuring CORS below.any

Configuring authentication

Authentication allows you to protect the monitoring endpoint from unauthorized acccess. It is important to set this on production hosting to disallow outside access if you are using monitoring endpoint as the unauthorized user can manage tunnel, client and link access.

There are two types of authorization you can set: basic and bearer.

Keep in mind that monitoring has bruteforce protection where user is kicked out for 5 minutes after 5 failed attempts.

Setting up basic authorization

Configuration will look like this:

{
    "server":{
        // ...other fields
        "endpoints":{
            "monitoring-endpoint": {
                // ...other fields
                "authentication": {
                    "type": "basic",
                    "username": "admin",
                    "password": "changethispassword"
                },
            }
        }
    }
}

This will setup a basic authorization method where browser will ask you to enter this username and password to access the endpoint.

Setting up bearer authorization

Bearer authorization is a more traditional token authorization as used in API requests. Your API client will send the token in Authorization: Bearer <token> header and if the token value is correct, tunnelize will grant access.

Configuration looks like this:

{
    "server":{
        // ...other fields
        "endpoints":{
            "monitoring-endpoint": {
                // ...other fields
                "authentication": {
                    "type": "bearer",
                    "token": "yourtoken",
                },
            }
        }
    }
}

Configuring CORS

CORS (Cross-Origin Resource Sharing) allows you to control which origins are permitted to access resources on your server. This is important for security, especially if your monitoring endpoint is accessed from web applications hosted on different domains.

You can configure CORS in the allow_cors_origins field. There are three types of CORS configurations you can set: any, none, and list.

Allow any origin

This configuration allows any origin to access the monitoring endpoint.

{
    "server":{
        // ...other fields
        "endpoints":{
            "monitoring-endpoint": {
                // ...other fields
                "allow_cors_origins": {
                    "type": "any"
                }
            }
        }
    }
}

Disallow all origins

This configuration disallows all origins from accessing the monitoring endpoint.

{
    "server":{
        // ...other fields
        "endpoints":{
            "monitoring-endpoint": {
                // ...other fields
                "allow_cors_origins": {
                    "type": "none"
                }
            }
        }
    }
}

Allow specific origins

This configuration allows only specified origins to access the monitoring endpoint. You need to provide a list of allowed origins.

{
    "server":{
        // ...other fields
        "endpoints":{
            "monitoring-endpoint": {
                // ...other fields
                "allow_cors_origins": {
                    "type": "list",
                    "origins": [
                        "https://example.com",
                        "https://anotherdomain.com"
                    ]
                }
            }
        }
    }
}

Make sure to configure CORS according to your security requirements to prevent unauthorized access from untrusted origins.

API endpoints

EndpointMethodDescription
/system/infoGETRetrieves system information including CPU usage, memory, and uptime.
/system/endpointsGETLists all configured endpoints on the server.
/system/endpoints/:nameGETRetrieves information about a specific endpoint by name.
/system/clientsGETLists all connected clients.
/system/clients/:idGETRetrieves information about a specific client by ID.
/tunnelsGETLists all active tunnels.
/tunnels/:idGETRetrieves information about a specific tunnel by ID.
/tunnels/:idDELETEDisconnects a specific tunnel by ID.
/linksGETLists all active links.
/links/:idGETRetrieves information about a specific link by ID.
/links/:idDELETEDisconnects a specific link by ID.