Page 1 of 1

Can Make mikrotik check if extrnal web proxy is working or ?

Posted: Tue Jun 22, 2010 12:49 pm
by stlony
Hello
I am working on Mikrotik v 3.30
I want to use Parent proxy but Connection is down to users if Parent proxy goes down, so i am asking if there is a way to make Mikrotik check this parent proxy every while and if it is down it he uses a direct connection.

all i want is a Method to check other proxy servers if it is working or not via mikrotik?

Thanks for People who is help others.

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Tue Jun 22, 2010 4:48 pm
by fewi
Yes. If you just want to watch for generic connectivity use NetWatch (see manual) to fire a script when the external proxy stops pinging, and another one when it starts pinging again. If you want to monitor on an application level make mangle/NAT rules that force the router itself through the proxy for specific transactions and schedule a script that in turn calls another script that sets a global to false, downloads the file, then sets the global to true. If the download fails (strong case that the proxy is down, but you MUST make sure the final download source is very, very reliable) that second script will error out and the global will never be set to true, so the first script can detect proxy failure and then take the appropriate actions.

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Tue Jun 22, 2010 6:04 pm
by stlony
Thanks for replay
for Netwatch i really try it but there is some proxys replar in ping but it is not replay in web proxy

and for
"If you want to monitor on an application level make mangle/NAT rules that force the router itself through the proxy for specific transactions and schedule a script that in turn calls another script that sets a global to false, downloads the file, then sets the global to true. If the download fails (strong case that the proxy is down, but you MUST make sure the final download source is very, very reliable) that second script will error out and the global will never be set to true, so the first script can detect proxy failure and then take the appropriate actions."

Would you please give me some samples

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Tue Jun 22, 2010 6:46 pm
by fewi
Sorry, I won't have time to script that out beyond general suggestions.
Maybe someone else will.

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Wed Jun 23, 2010 9:29 am
by stlony
Thanks for you
I got what you mean but just i want you to mention the commands to do the following actions and i will learn them and continue:
How can i force the router through the proxy?
How can i set the global to true or to false?
What you mean by monitor application level?

For example:
How can i downloads the file?
you can download the file using command "tool/fetch"

Just this what i want for now.

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Wed Jun 23, 2010 3:00 pm
by stlony
Any Help!!

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Wed Jun 23, 2010 10:40 pm
by stlony
Huuuuuup

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 3:28 pm
by stlony
Please fewi help just tell me

How can i force the router through the proxy?
How can i set the global to true or to false?

and i will Make all scripts


Please help no one else answer

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 3:32 pm
by Chupaka
make mangle/NAT rules that force the router itself through the proxy for specific transactions
unfortunately, you cannot dst-nat connections of local facilities... so at least you need two routers...

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 3:42 pm
by stlony
Chupaka
that if i want to do this "make mangle/NAT rules that force the router itself through the proxy for specific transactions"

What about the main problem

"all i want is a Method to check other proxy servers if it is working or not via mikrotik?"

is there any way to do this in your mind?

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 4:14 pm
by Chupaka
sorry, I can't see the way to do it by ROS means... I'd post it if I know...

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 4:17 pm
by stlony
Thanks for help brother

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 4:28 pm
by fewi
Yeah, I was wrong. Destination NAT is before output, so you can't destination NAT router originated traffic. Instead of two routers you could also use a server behind the router that detects proxy failure and uses the API to make configuration changes but I agree that you can't do it natively in one router.

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 4:39 pm
by stlony
and what is API?

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 4:53 pm
by Chupaka
API is a way your program may interact with router... you need additional server anyway

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 5:22 pm
by stlony
ok is there a way to make another program check the proxy and change the mikrotik settings via windows but (Auto i mean) i have a program to check the proxy but how i can change the settings

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Thu Jun 24, 2010 7:15 pm
by kazanova
can you give as name of programme

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Fri Jun 25, 2010 10:38 am
by stlony
What you mean by give as name

it seems you are Masri i am also

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Fri Jun 25, 2010 7:18 pm
by Chupaka
he means, 'give us' =)

what program do you use for proxy checking?

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Fri Jun 25, 2010 10:49 pm
by kazanova
Chupaka that what i mean

iam lebanes :D

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Mon Jun 28, 2010 2:20 pm
by stlony
Program called:

Proxy switcher

Re: Can Make mikrotik check if extrnal web proxy is working

Posted: Sat Apr 06, 2013 1:25 am
by klibby
Although this may not help the original poster since this is an old topic, I came across this and was running into the same issue fewi pointed out:
Destination NAT is before output, so you can't destination NAT router originated traffic. Instead of two routers you could also use a server behind the router that detects proxy failure and uses the API to make configuration changes but I agree that you can't do it natively in one router.
Although I found a solution to this, so if anybody like me comes across this thread, you can have the check process scripted in the same box. You don't need a destination NAT rule to force the MikroTik's http request through the proxy, instead you can point /tool fetch to your proxy using the address, host, src-path and method arguments instead of 'url'
/tool fetch address=10.10.10.10 host=www.example.com src-path=status.txt method=http;
Where 10.10.10.10 is the proxy server's IP

Instead of:
/tool fetch url="http://www.example.com/status.txt";
Below is a group of scripts that worked for me. You can add these, then setup a scheduler to run "check_status" at whatever interval you desire.
#### script: check_status
# Edit the following values for your configuration:
# 
# proxyIP = IP Address of your proxy server
# host = Domain name where your status page is hosted.
# path = Path for status page.
# vString = Some text to look for on status page to confirm proxy is online.
# timeout = Time in seconds to wait for fetch to download page before failing.
#
# As set, this would check that "some text to verify" is included on
# page downloaded from http://www.example.com/status.html
# via proxy server at 10.10.10.10:8080
#
:global proxyIP "10.10.10.10";
:global host "www.example.com";
:global path "status.html";
:global port 8080;
:global vString "some text to verify";
:local timeout 3;
:global fstatus;
:execute fetch_status;
:local count 0;
:while ( $fstatus != "success" && $count < ($timeout*10) ) do={
	:set count ($count+1);
	:delay 0.1;
	}
:if ($fstatus = "success") do={
	:execute check_proxy;
	} else={
	:execute disable_proxy;
	}
/system script environment remove [/system script environment find name=fstatus];

#### script: fetch_status
:global fstatus;
:global proxyIP;
:global host;
:global path;
:global port;
/tool fetch address=$proxyIP port=$port host=$host src-path=$path dst-path="status.txt" mode=http;
:set fstatus "success";

#### script: check_proxy
:global vString;
:local result [/file get status.txt contents];
:if ($result~$vString) do={
	:execute enable_proxy;
	} else={
	:execute disable_proxy;
	}
/file remove [/file find name~"status.txt"];

#### script: enable_proxy
# Script to run if proxy is online.

#### script: disable_proxy
#script to run if proxy is offline.

This will first check if the MikroTik can access the status page you specified through the proxy. Next it will verify some string exists within the status page to ensure you're not just seeing some redirect from the proxy. On the status page, you might also want to include the NO-CACHE meta tag. My status page is simple:
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head>
<body>
proxy-okay
</body>
</html>

Re: Can Make mikrotik check if extrnal web proxy is working or ?

Posted: Thu Apr 16, 2015 11:55 am
by stlony
Thanks a lot for giving hand :)
I just read it today