Set Proxy server automatically for clients

Hello guys. I have a Proxy server inside of my LAN network, And I want to all of my clients on the network, pass through that specific Proxy to access to the Internet, no matter it's smartphone, laptop, PC and etc... just access the WAN by connecting to that Local proxy server.
So what is the best way to do that?

Device: TP-Link TD-W8970 v1
OS: OpenWRT 19.07.3
Proxy type: accepting all protocols(http, htpps, socks v4 and v5 ...) and also authentication is NOT necessary.

I think you are looking for wpad.

2 Likes

How can I implementation and configure it on OpenWRT?

As far as OpenWrt is concerned, you can add the option 252 in dhcp options under the interface you want to enable it.
The rest is generic. You can search for examples of wpad.dat and put it on a webserver. If you can convert OpenWrt to serve the wpad.dat from a webserver running on it, you won't need another server.

2 Likes

I searched for that but I can't find any complete solution to doing that.
Are this one is OK?
https://findproxyforurl.com/deploying-wpad/

The page you mentioned is only one part for configuring webserver, dhcp, and dns. You also need to create the pac file, mentioned in the examples.

These are the steps you need to follow:

  • You first need to configure the PROXY server, and check that it works configuring a client manually.
  • Now you need an HTTP server, put a "wpad.dat" file there, and again check with a client that it works, configuring it manually as a "setup script" or how it is called in your OS.
  • Finally, configure the DHCP server on the network router, to announce the configuration script, using option 252.

Tell us how far you got on each step, and we will try to help you.

1 Like

OK, I guess it's done now. I can access to my wpad.dat using the http://wpad/wpad.dat in my LAN network, and I test my wpad.dat and it works.
But I don't know how to add option 252 to my OpenWRT? which file I must edit and what I expected to insert there?

At "/etc/config/DHCP", add a line like this one:

list dhcp_option '252,"http://wpad/wpad.dat"'
3 Likes

OK. this is my DHCP file now:

config dhcp 'lan'
	option interface 'lan'
	option dhcpv6 'server'
	option ra 'server'
	option start '2'
	option leasetime '6h'
	option limit '10'
	option ra_management '1'
	list dhcp_option '252,"http://wpad/wpad.dat"'

But I don't see any difference! when a new computer joins the network, It must get this configuration automatically, right? like windows, smartphone and etc...

That looks good to me... I think you need to debug it, and see why it is not working.

1 Like

Is there a hostname alias for wpad to resolve the IP of the web server which hosts the wpad.dat file?

1 Like

Currently when I type http://wpad/wpad.dat in my browser, it shows me the contents of wpad file.
If I go to Wi-Fi setting in my IPhone and set the HTTP PROXY to Automatic and leave the URL box, It gets the configuration automatically. But there is three problems:

  1. It's not really an automated job! I still need to make some settings manually for each device.

  2. It's HTTP PROXY, as IPhone called it. Using the web browsers, It's OK,but I have problem with the applications which DoNot supports HTTP Protocol, so they bypass the PROXY and I still have to use 3rd apps to connect to SOCKS 5.

  3. In windows OS, still nothings happen!

Perhaps I did not understood your message, but for all this to work, all clients must be manually configured to "automatic". The default configuration is not to use any proxy at all, and you cannot change that from the router.

Perhaps what you need is a transparent proxy?

2 Likes

OK, I got it. I expect after doing all of this, I don't need to waste my time for each client and everything done by itself. Rather, I noticed It's useless for IPhone, because it's just apply on HTTP Protocol, which doesn't meet what I want(It not be able to handle my apps). also for android, it doesn't support more than HTTP PROXY by default.
The diffrence between IPhone and Android actually is, in IPhone you can just set HTTP PROXY to auto and leave the URL field(IOS will find it by itself), but in Android you have to go forward and set the exact location to the wpad.dat file. I think I have to install 3rd proxy apps for mobile phone.

Update: In windows, when I get back to LAN settings and check the automatically detect settings, which I was Unchecked this before, the OS now be able to get configuration automatically, also it supports socks 5, so I have no problem with my programs. That's awesome! Thanks to you guys @eduperez @trendy :+1:

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.