Server Monitoring

Monitoring Private Servers

By: Shane Harter|Last Updated: Aug 02, 2022

Monitoring cron jobs, scripts and daemons on servers without internet access can be done by establishing a limited proxy server on a peer machine capable of making requests to the Cronitor Telemetry API.

Configuring your Nginx proxy

Any proxy server can be used, but this guide will demonstrate using the Nginx reverse proxy server to route Cronitor pings from your private network to our public API.

  1. Nginx can be installed using package managers like apt-get and yum, or by downloading from http://nginx.org/en/download.html. Installation is easy and will take only a few moments.
  2. Unlink the default configuration file using
$ sudo unlink /etc/nginx/sites-enabled/default
  1. Create a new nginx config file, customizing the IP address and CIDR range below for your use
$ sudo vim /etc/nginx/sites-available/cronitor-proxy
server {
        listen 80;

        # Make site accessible from its IP, in this example 192.168.50.5
        server\_name 192.168.50.5;
        location / {
                resolver 8.8.8.8;
                proxy\_pass https://cronitor.link:443$request\_uri;

                # Set this to the CIDR range of your isolated server(s)
                allow 192.0.0.0/8;
                deny all;
        }
}
  1. Create a symlink to enable this new config
$ sudo ln -s /etc/nginx/sites-available/cronitor-proxy /etc/nginx/sites-enabled/cronitor-proxy
  1. Restart nginx, for example on Ubuntu: $ sudo service nginx restart

Your nginx proxy is now configured to accept incoming requests from your private network on port 80 and forward them over an SSL connection to the Cronitor ping API. The proxy cannot be used to access anything else.

Using your proxy server with Curl

If you are using Curl to ping Cronitor, you can begin to forward requests to your internal proxy simply by setting an environment variable. You can set this directly in most implementations of crontab:

http\_proxy=192.168.50.5:80

# m h dom mon dow   command
0 1 \* \* \* /path/to/job.sh &&
curl https://cronitor.link/d3x0c1/complete -m 10

If you are using Curl outside of crontab, you can set this variable in your bash profile

$ echo "export http\_proxy=192.168.50.5:80" >> ~/.bash\_profile; source ~/.bash\_profile

Note that by default Crontab uses /bin/sh and environment variables set in your shell profile will not be available in crontab.

With this variable set, you can follow instructions as written in the in telemetry API with one caveat: To avoid complexity of installing a self-signed SSL certificate, your proxy server is only listening on port 80. When pinging Cronitor, use http:// not https:// — your requests will be relayed over an SSL secured connection by the proxy server.

Using your proxy server with other HTTP clients

Most HTTP clients have built-in support for using a proxy server, so the first step would be to consult your documentation. Alternatively, you could just send your pings directly to your proxy, converting a URL like http://cronitor.link/d3x0c1/run to http://192.168.50.5/d3x0c1/run, substituting the IP of your proxy.

Previous
What is Heartbeat Monitoring