Community discussions

MikroTik App
 
ahead
just joined
Topic Author
Posts: 17
Joined: Sat Sep 24, 2011 11:22 pm

Set Web Proxy Address In Browser Automatically?(Like WPAD)

Wed Sep 28, 2011 11:39 pm

I configed WebProxy And DHCP On Mikrotik And
When I Manually Set Web Proxy Address In My Browser(IE/Firefox), everything Work Correct
Now how Can I Config MikroTik To Set Web Proxy Address In Browser Automatically (Like WPAD On Isa/TMG )?....
What I Must Do In Mikrotik?
 
User avatar
zervan
Member
Member
Posts: 329
Joined: Fri Aug 20, 2010 10:43 pm
Location: Slovakia
Contact:

Re: Set Web Proxy Address In Browser Automatically?(Like WPA

Thu Sep 29, 2011 12:07 am

a) WPAD could be set automatically (only in Internet Explorer) from DHCP - you have to add DHCP option, for example:
/ip dhcp-server option
add code=252 name=auto-proxy-config value=http://wpad.intranet/wpad.dat
(where value is address of your wpad script) and then use it in DHCP server network, for example:
/ip dhcp-server network
add address=192.168.100.0/24 dhcp-option=auto-proxy-config dns-server=192.168.100.1 gateway=192.168.100.1
b) More general way is to set configuration script URL in each browser (IE, Opera, Firefox), for example: http://wpad.intranet/wpad.dat - you don't need to do anything on Mikrotik, but static DNS record may be useful (for example mentioned wpad.intranet).

Both ways need a webserver to place WPAD configuration script on.
 
Feklar
Forum Guru
Forum Guru
Posts: 1724
Joined: Tue Dec 01, 2009 11:46 pm

Re: Set Web Proxy Address In Browser Automatically?(Like WPA

Thu Sep 29, 2011 6:03 pm

You can force people to use the proxy with a NAT rule. It only works for HTTP though, it will not work for HTTPS.
/ip firewall nat
add action=redirect chain=dstnat dst-port=80 protocol=tcp
 
ahead
just joined
Topic Author
Posts: 17
Joined: Sat Sep 24, 2011 11:22 pm

Fri Sep 30, 2011 12:06 am

Thanks For Your Answers...But It's Not Work...
This Is My Config:
000.JPG
001.JPG
There Is Several Question In My Mind Now:
1.Should I Create wpad.dat Manually(_Mikritik Did Not create it Automatically? Like Microsoft ISA Or TMG)
2.If I Must Create Wpad.dat File Then What Is the WPAD Scrip?How Creat it? And Where I Must Place WPAD.DAT File????
3.If I Must Place WPAD.DAT File Manually Then How Can I Place it On Mikrotik Itself And set DHCP Option Value=http://<Mikrotik Ip>/wpad.txt ?
4.On Several Forum I Read That DHCP Code for Wpad Is 249 Not 255 (_if This may Help:I Use Licecnce Level 6)?
You do not have the required permissions to view the files attached to this post.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Set Web Proxy Address In Browser Automatically?(Like WPA

Fri Sep 30, 2011 12:37 am

You misunderstood him.

You have to manually create the wpad.dat file. Also, the router can't act as the web server serving that file. That's why he said you need a web server.
 
User avatar
zervan
Member
Member
Posts: 329
Joined: Fri Aug 20, 2010 10:43 pm
Location: Slovakia
Contact:

Re:

Fri Sep 30, 2011 10:00 am

1.Should I Create wpad.dat Manually(_Mikritik Did Not create it Automatically? Like Microsoft ISA Or TMG)
Yes, you have to prepare it manually.
2.If I Must Create Wpad.dat File Then What Is the WPAD Scrip?How Creat it? And Where I Must Place WPAD.DAT File????
Here you can find some information: http://en.wikipedia.org/wiki/Web_Proxy_ ... y_Protocol
http://blog.freyguy.com/archives/2006/0 ... d-firefox/

It should contain at least something like this:
function FindProxyForURL(url, host) { return "PROXY proxy.intranet:8080"; }';
- where proxy.intranet is name or IP address of your proxy (Mikrotik) and 8080 is it's TCP port. But you may use something more sofisticated, of course.

I use this PHP script in index.php on my local web server:
<?php
if (isset($_REQUEST["wpad"]))
{
  header("Content-Type: application/x-ns-proxy-autoconfig; charset=utf-8");
?>
function FindProxyForURL(url, host)
{
  if (dnsDomainIs(host, ".local") || dnsDomainIs(host, ".intranet") || isPlainHostName(host) || shExpMatch(host, "192.168.1.*"))
    return "DIRECT";
  return "PROXY proxy.intranet:8080";
}
<?php
}
else
  header("location: http://www.mywebsite.x");
It is good if WPAD script is listening to various names, so I made this .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^wpad
  RewriteRule .* index.php?wpad=1 [L]
RewriteRule ^wpad\. index.php?wpad=1 [L]
RewriteRule ^wspad\. index.php?wpad=1 [L]
RewriteRule ^proxy\.pac index.php?wpad=1 [L]
- it is listening not only to file named wpad.dat, but also any wpad.* file and also on DNS name of server wpad.
3.If I Must Place WPAD.DAT File Manually Then How Can I Place it On Mikrotik Itself And set DHCP Option Value=http://<Mikrotik Ip>/wpad.txt ?
Unfortunately, Mikrotik is not a webserver, so you have to use your local webserver or maybe webserver on internet (but you have to add it to Walled Garden then) :(
4.On Several Forum I Read That DHCP Code for Wpad Is 249 Not 255 (_if This may Help:I Use Licecnce Level 6)?
I have found value of 252 as right value and it is working for me in Internet Explorer. I didn't try value of 249, but you can try and let me know.
 
ahead
just joined
Topic Author
Posts: 17
Joined: Sat Sep 24, 2011 11:22 pm

Re: Set Web Proxy Address In Browser Automatically?(Like WPA

Fri Sep 30, 2011 2:17 pm

It's Not Work again...
wpad.dat Script File Is Like This:

function FindProxyForURL(url, host)
{ return "PROXY 172.19.95.3:8080 ; DIRECT"; }
10.jpg
11.jpg
12.jpg
I run iis service on my server and add wpad.dat file...
but Even I set _Use automutic configuration Script_ on IE setting nothing Happens...
(172.19.95.1 :My iis server -- 172.19.95.3 : my mikrotik )
You do not have the required permissions to view the files attached to this post.
 
User avatar
zervan
Member
Member
Posts: 329
Joined: Fri Aug 20, 2010 10:43 pm
Location: Slovakia
Contact:

Re: Set Web Proxy Address In Browser Automatically?(Like WPA

Fri Sep 30, 2011 2:34 pm

You have checked option "Use automatic configuration script" and set address - that's right, but this doesn't need any DHCP settings, so if this is what you want make to work, forget about DHCP option and the problem is more simple now. (DHCP assignment is applied when you check "Automatically detect settings" only.)

Well, but it is not working for you.. Try to put address "http://172.19.95.1/wpad.dat" to your browser - is it working and displaying script? If it does, that's good.

Now turn off your browser, turn it on again and try to open any webpage. Check your webserver's log if file wpad.dat was requested - it should be - web browser will at first ask for WPAD script and after that for webpage.

If the wpad.dat file was requested, then something other is wrong. Maybe you should define content type for wpad.dat as: application/x-ns-proxy-autoconfig - but I don't know how to do this on IIS.
 
ahead
just joined
Topic Author
Posts: 17
Joined: Sat Sep 24, 2011 11:22 pm

Re: Set Web Proxy Address In Browser Automatically?(Like WPA

Fri Sep 30, 2011 10:16 pm

when i put address "http://172.19.95.1/wpad.dat" in browser I Get "The page cannot be found" Message
but Something Interest...
when I change Wpad File Extension To .txt/.doc/.htm/.js And also set _Use automatic configuration Script_ on IE setting It Working...
but even I change File Extension on dhcp option and then select automatically detect setting on IE, it's not work.....
Any Idea....
 
User avatar
zervan
Member
Member
Posts: 329
Joined: Fri Aug 20, 2010 10:43 pm
Location: Slovakia
Contact:

Re: Set Web Proxy Address In Browser Automatically?(Like WPA

Sat Oct 01, 2011 8:30 am

when i put address "http://172.19.95.1/wpad.dat" in browser I Get "The page cannot be found" Message
Check your webserver settings - the WPAD file must be accessible.
when I change Wpad File Extension To .txt/.doc/.htm/.js And also set _Use automatic configuration Script_ on IE setting It Working...
So http://172.19.95.1/wpad.txt is working in browser as well? It seems that you have some rule that denies access to .dat files.
but even I change File Extension on dhcp option and then select automatically detect setting on IE, it's not work.....
Well, this is another problem. To apply DHCP setting it is necessary to renew address (in windows: ipconfig -release & ipconfig -renew) or restart computer. Also check in web server's log if the file is requested - it should be.

Who is online

Users browsing this forum: adrianmartin16, Amazon [Bot], Qanon, Rockyboa, senseivita and 82 guests