Mikrotik RouterOS Web Proxy in Transparent Mode
Mikrotik RouterOS Web Proxy in Transparent Mode
Mikrotik RouterOS Web Proxy in Transparent Mode
It can cache certain contents / http pages in its local cache. Mikrotik have basic PROXY package builtin called WEB PROXY. It is suitable for basic caching for small to mid size networks. For advance caching capabilities, Use 3rd party external proxy server like SQUID.
Lets BEGIN . . .
. Now go to STORES tab (by navigating to SYSTEM > STORES) Select the WEB-Proxy package and click on COPY It will ask you where to copy WEB-Proxy package, Select Secondary Drive in TO box.
Now Click on Enable in Port, Type 8080 Max Cache Size , Select Unlimited from drop down menu, OR if you have limited Disk Space, then use your desired amount. You have to specify space in KiloBytes for example 1024 KB = 1MB , so if you want to set 5 GB Cache, then use 5242880 , I am using 5 GB in this example. The cache size is really based off of how much RAM you have in the machine
. Click on Apply and your Mikrotiks Web Proxy is Ready to be used, But Every client have to set proxy address pointing to Mikrotik IP to be able to use Proxy Service.
3# Transparent Proxy
If we want that every user must be automatically redirected to Proxy transparently, then we have to create additional rule to forcefully redirect users to proxy service, which is calledTRANSPARENT PROXY. . Goto IP > FIREWALL > NAT and create new rule In Chain , Select dsntant, In Protocol, Select 6 (tcp) In Dst. Port, Type 80
. Now goto Action Tab, In Action, Select redirct In To Ports, Type 8080
. Now your newly created rule will look like something below image.
Howto Send CACHED Contents to user at Full Speed / Ignoring QUEUE Limit for cached-hits marked packets
1 2 3
/ip firewall mangle add action=mark-packet chain=output comment="CACHE HIT/Zaib" disabled=no dscp=4 \ new-packet-mark=cache-hits passthrough=no
Now Create an Queue Tree which will send cache-hits packets to users at full LAN speed, ignoring the users Static OR Dynamic QUEUES
1 2 3 4
/queue tree add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \ max-limit=0 name="Unlimited Speed for CACHE by zaib" packet-mark=cache-hits \ parent=global-out priority=8 queue=default
Now Try to download any cacheable content , for example download following file, http://www.rarlab.com/rar/wrar410b5a.exe Once Downloaded, Try to download it again from any other computer or via same test pc. You will see the Queues and rules in action, sending cache-hits packets to users at full LAN speed.Remember Mikrotik web proxy is very basic and simple proxy server with not much tweaks and nuts N Bolts to set, So it will cache what it can. For advancements, Use SQUID instead.
. Also you can view the cache contents via going to IP > WEBPROXY > CACHE CONTENTS
You can block any web site via domain name as shown below.
1 2
/ip proxy access add action=deny disabled=no dst-host=yahoo.com /ip proxy access add action=deny disabled=no dst-host=www.yahoo.com
firewall filter 1/ip add action=drop chain=input comment="Block Open PROXY <img src="http://s0.wp.com/wp-inc 2disabled=no dst-port=8080 in-interface=wan protocol=tcp src-address=0.0.0.0/0
In in-interface , select your WANinterface.
Just copy this error.html file to your desktop and edit it using your favorite html editor. (I personally use MS FRONTPAGE 2003 due to its easy and user friendly interface, You can use notepad to edit this file content as its very small and contains basic text only. just dont mess with the code s, only change the text you want, for example network name support numbers etc. after saving , upload it back to Mikrotiok under web-proxy section.)
1 2 3
/ip proxy access add action=deny comment="Block yahoo for single user" disabled=no dst-host=www.yaho (192.168.2.5 is the user ip)
To block single user and redirect him to your policy page on any loacl web server defining the reason why he is blocked , use the following.
1 2
/ip proxy access add action=deny comment="Block yahoo for single user" disabled=no dst-host=www.yaho
(192.168.2.3 is the web server ip , & 192.168.2.5 is the user ip)