Proxy server features:
[MikroTik] > system package print Flags: I - invalid # NAME VERSION BUILD-TIME UNINSTALL 0 system 2.5.2 apr/24/2002 11:52:28 no 1 routing 2.5.2 apr/24/2002 12:04:34 no 2 web-proxy 2.5.2 apr/24/2002 12:02:52 no 3 ppp 2.5.2 apr/24/2002 11:57:03 no 4 pptp 2.5.2 apr/24/2002 11:57:43 no 5 pppoe 2.5.2 apr/24/2002 11:58:46 no 6 ssh 2.5.2 apr/24/2002 11:54:52 no 7 snmp 2.5.2 apr/24/2002 11:53:10 no [MikroTik] >
It is recommended, that at least 100MB HDD is used when running web proxy. Do not try to run web-proxy on a 32 or 48 MB FlashDisk!
[MikroTik] ip web-proxy> ? HTTP proxy clear-cache Clear http cache access Access list cache Cache access list print Print current configuration and status get Get value of configuration property set Change proxy configuration export Export web proxy settings [MikroTik] ip web-proxy>
For web proxy setup, do the following:
/ip dns set primary-dns=192.168.1.1
/ip web-proxy set address=0.0.0.0:8080
/ip web-proxy set parent-proxy=192.168.1.1:8080
otherwise disable it:
/ip web-proxy set parent-proxy=0.0.0.0:0
/ip web-proxy set cache-administrator=support@mt.lv
/ip web-proxy set hostname=proxy.mt.lv
/ip web-proxy set enabled=yes
Now it is possible to use this proxy, by setting it as proxy for IE or Netscape.
Web proxy will automatically detect any problems with cache and will try to solve them without loosing any cache data. But in case of a heavy damage to the file system, the web proxy can't rebuild cache data. Cache can be deleted and new cache directories created by the command '/ip web-proxy clear-cache'.
[MikroTik] ip web-proxy> print enabled: yes address: 0.0.0.0:8080 transparent-mode: no parent-proxy: 0.0.0.0:0 cache-administrator: support@mt.lv hostname: proxy.mt.lv status: running reserved-for-cache: 6782 MB [MikroTik] ip web-proxy>
Description of the status parameter value:
stopped- proxy is disabled and is not running
rebuilding-cache代理启用并运行,现有的缓存being verified
running- proxy is enabled and running
stopping- proxy is shutting down (max 10s)
clearing-cache- proxy is stopped, cache files are being removed
creating-cache- proxy is stopped, cache directory structure is being created
dns-missing- proxy is enabled, but not running because of unknown DNS server (please, specify it under /ip dns)
invalid-address- proxy is enabled, but not running because of invalid address (please, change address or port)
invalid-cache-administrator- proxy is enabled, but not running because of invalid cache-administrator's e-mail address
invalid-hostname- proxy is enabled, but not running because of invalid hostname (please, set valid hostname value)
error-logged- proxy is not running because of unknown error. This error is logged as System-Error. Please, send us this error and some description, how it happened.
Access logs are sent to Web-Proxy-Access logging facility. These logs can be disabled, logged locally or sent to remote address. To log locally:
/system logging facility set Web-Proxy-Access logging=localLogs can be viewed using/log printcommand.
Access list is implemented in the same way as MikroTik firewall rules. Rules are processed from top to bottom. First matching rule specifies decision of what to do with this connection. Connections can be matched by its source address, destination address, destination port or substring of requested url. If none of these parameters is specified, every connection will match this rule.
If connection is matched by a rule, action property of this rule specifies whether connection will be allowed or not. If connection does not match any rule, it will be allowed.
For example:
[雷竞技网站MikroTik] ip web代理访问>打印标志:X - disabled # SRC-ADDRESS DST-ADDRESS DST-PORT URL ACTION 0 0.0.0.0/0 0.0.0.0/0 0-65535 .mp3 deny 1 10.0.0.1/32 0.0.0.0/0 0-65535 allow 2 0.0.0.0/0 0.0.0.0/0 0-65535 ftp:// deny 3 10.0.0.0/24 10.9.9.128/28 0-65535 allow 4 0.0.0.0/0 0.0.0.0/0 0-65535 deny [MikroTik] ip web-proxy access>
Argument description:
src-address- source address of the request
dst-address- destination address of the request
dst-port- destination port of the request
url- the URL of the request. Can be regular expression.
action- (allow / deny) action to take.
Access list, shown above, disables access to any mp3 files for everyone.
Local gateway 10.0.0.1 has access to everything else (excluding mp3 files).
All other local network (10.0.0.0/24) users have access to servers located at 10.9.9.128/28, but, ftp protocol is not allowed for them.
Any other request is denied.
Cache access list specifies, which requests (domains, servers, pages) have to be cached locally by web proxy, and which not. The Web Proxy cache access list is located under the/ip web-proxy cachesubmenu.
Access list is implemented exactly the same way as web proxy access list. Default action is to cache object (if no matching rule is found). By default, one cache access rule is already added:
[MikroTik] ip web-proxy cache> print Flags: X - disabled # SRC-ADDRESS DST-ADDRESS DST-PORT URL ACTION 0 0.0.0.0/0 0.0.0.0/0 0-65535 cgi-bin \? deny [MikroTik] ip web-proxy cache>This rule defines, that all runtime generated pages (which are located within cgi-bin directories or contain '?' in url) has not to be cached.
NOTE:Objects, which are larger than 4MB, are not cached.
[MikroTik] ip web-proxy> print enabled: yes address: 0.0.0.0:8080 transparent-mode: yes parent-proxy: 0.0.0.0:0 cache-administrator: support@mt.lv hostname: proxy.mt.lv status: running reserved-for-cache: 3398 MB [MikroTik] ip web-proxy>
If we want all connections coming from interface ether1 and going to port 80 to handle with web proxy transparently, and if our web proxy is listening on port 8080, then we add following destination nat rule:
[MikroTik] ip firewall dst-nat> add in-interface=ether1 protocol=tcp \ dst-address=!10.0.0.1/32:80 action=redirect to-dst-port=8080 [MikroTik] ip firewall dst-nat> print Flags: X - disabled, I - invalid 0 ;;; Transparent proxy src-address=0.0.0.0/0:0-65535 in-interface=ether1 dst-address=!10.0.0.1/32:80 protocol=tcp icmp-options=any:any flow="" src-mac-address=00:00:00:00:00:00 limit-count=0 limit-burst=0 limit-time=0s action=redirect to-dst-address=0.0.0.0 to-dst-port=8080 bytes=118949 packets=2260 [MikroTik] ip firewall dst-nat>
Here, the router's address and port 80 (10.0.0.1/32:80) have been excluded from redirection to preserve the winbox functionality which uses TCP port 80 on the router. More than one redirect rule can be added to redirect more than one port.
NOTE:only HTTP traffic is supported by web proxy transparent mode. HTTPS and FTP are not going to work this way!