-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.php.tmpl
More file actions
29 lines (25 loc) · 761 Bytes
/
proxy.php.tmpl
File metadata and controls
29 lines (25 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$offset = strtotime('+24 hours');
$expStr = "Expires: " . gmdate("D, d M Y H:i:s", $offset) . " GMT";
header("Content-type: application/x-ns-proxy-autoconfig");
header("Cache-Control: no-cache, must-revalidate");
header($expStr);
if(isset($_SERVER['SERVER_NAME'])) {
$clientip = $_SERVER['SERVER_NAME'];
} else {
$clientip = $_SERVER['SERVER_ADDR'];
}
?>
function FindProxyForURL(url, host) {
var proxy_yes = "PROXY <?php echo $clientip ?>:3128";
var proxy_no = "DIRECT";
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
{{ range $index, $value := $containers }}
{{ $network := index $value.Networks 0 }}
if (shExpMatch(host, "{{ $host }}")) {
return proxy_yes;
}
{{ end }}
{{ end }}
return proxy_no;
}