Easily check if web service available outside the local network

Open Sauce Projects - Sep 15 '22 - - Dev Community

When is this relevant?

  • If you have a web service on your local network you want check if its accessible publicly on the internet.

What do i need?

  • It's a bit of a hack, but you can use google translate as a proxy. From here in google translate you can get a url from which you can access your site's translated version. The site might not render properly but the important thing is that this url will always point to your website. So if this site is available so is yours and vice versa.
  • You can do a GET request and test for site availability in two ways.

    • Do a keyword search if you know a word that should always appear on the site
    • Another way is to check the request's status code, if it's not 200 the site is most likely down.
    • You can monitor this with a scheduled script that would notify you if the site is down, here's a simple python example:
    import requests  
    url="'translated' url"  
    keyword=""  
    r=requests.get(url)  
    if keyword not in r.text:  
        print("send notification")  
    # or  
    if r.status_code!= 200:  
        print("send notification")
    
  • For less headaches instead of a script i would suggest downloading Uptime kuma which is specifically made for checking website status, it supports status code and keyword checking and a lot more. It has a lot of options for notifications, not limited to but including Telegram, Discord, Gotify, Slack, Pushover, Email (SMTP) and it has a nice web ui.

  • Uptime Kuma dashboard

Soo

  • I hope it was helpful in some way, if you have an alternative idea be sure to comment it below.
. . . . . . . .