I have several websites running inside docker containers. And since there are several docker containers running on the same server, for each of them a redirection is setup using nginx. Now I want to write a simple shell script to check periodically if the url is available. What I've tried is
echo $(curl mysubhost.com --write-out '%{http_code}' --silent --output /dev/null servername)
Now, because of redirection I always get a result code 301000
Even when the container is stopped, or the apache service inside the container is stopped I always get the same result code because the nginx
makes redirection in the layer of the server.
What is the proper way to monitor if my websites are available? One of the way is to check if the containers are running, but that's not enough, since the containers can be up and running but there can be a lot of reasons for the websites to be unavailable.
Nginx proxy looks like
server {
server_name mysubhost.com www.mysubhost.com;
location / {
proxy_pass http://127.0.0.1:100;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_ssl_verify off;
}}