3 - the file exists in the path, but the configuration inside does not show anything
One related issue that I found is that if you disable redirection from 80->443 you lose the ability to load wpad from HTTP. See https://github.com/opnsense/core/issues/3416
/* add HTTP to HTTPS redirect */ if ( $config['system']['webgui']['protocol'] == 'https' && !isset($config['system']['webgui']['disablehttpredirect']) ) { $redirectport = $lighty_port != "443" ? ":{$lighty_port}" : ''; foreach ($listeners as $listener) { if (is_ipaddrv6($listener)) { $listener = "[{$listener}]"; } $lighty_config .= <<<EOD\$SERVER["socket"] == "{$listener}:80" { \$HTTP["host"] =~ "(.*)" { url.redirect = ( "^/wpad.dat" => "" , "^/(.*)" => "https://%1{$redirectport}/$1" ) }}
admin@OPNsense:/tmp % cat /usr/local/www/wpad.dat/* PAC file created via OPNsense To use this file you have to enter its URL into your browsers network settings.*/function FindProxyForURL(url, host) {if (((!isPlainHostName(host)) && (!shExpMatch(host, "*.home.lan")))) {return "PROXY 192.168.1.1:3128";} // If no rule exists - use a direct connection return "DIRECT";}
curl --header "X-Forwarded-For: other.net" -I 192.168.1.1/wpad.datHTTP/1.1 301 Moved PermanentlyLocation: https://192.168.1.1/wpad.datDate: Sat, 13 Jun 2020 18:57:44 GMTServer: OPNsense
$ dig -t txt opnsense; <<>> DiG 9.11.19-RedHat-9.11.19-1.fc31 <<>> -t txt opnsense;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29865;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096;; QUESTION SECTION:;opnsense. IN TXT;; Query time: 0 msec;; SERVER: 192.168.1.1#53(192.168.1.1);; WHEN: Sa Jun 13 21:12:17 CEST 2020;; MSG SIZE rcvd: 37
You need to deliver it via HTTP as well. In your case you get a 302 because you are redirected to the HTTPS port.