Cloud Monitoring Uptime checks allow users to send a request to a resource to see if it respond.
Since the checks are performed outside Google Cloud infrastructure, an external ip is needed.
Is there a way to implement Uptime checks for sites ( http requests ) that does not have a public IP?
Best Answer
TL;DR: yes, by using a bastion host with external IP that can query reach the internal site and use a proxy ( NGINX , SquidProxy , etc ) to pass your health check request from the external services to your internal sites.
What you need:
The process:
If you want to skip the installation process, you may choose to use NGINX PLUS and install it by using Google Cloud MarketPlace
You can also use NGINX Docker container for this task.
Some tips and tricks on how to configure nginx
When you install NGINX by following NGINX’s instructions, you will get a functional NGINX at the end of the process. But you may need extra configurations to achieve the goal.
/etc/nginx/conf.d/default.conf
to answer a 404 to any request that does not includes a valid HOST header:Create a configuration file under
/etc/nginx/conf.d/
directory for each site you want to monitor. i.e./etc/nginx/conf.d/finance-sites.conf
. Do not forget the .conf termination.Set a bogus host for each site you want to monitor and do not forget to set the host header in Cloud Monitoring.
Do not forget to check syntax
nginx -t
and reload configurationnginx -s reload
each time you perform a change in your configuration.