De:Autoconfig
Inhaltsverzeichnis
Proxy-Autokonfiguration für alle Browser
In nahezu allen gängigen Browsern ist eine Möglichkeit vorhanden, eine Autokonfigurationsadresse für den Proxy anzugeben.
Die Orte dafür sind unterschiedlich, suchen Sie sinngemäß nach "Automatischer Proxy Konfigurations-URL".
YaCy unterstützt diese Möglichkeit, die zugehörige Adresse lautet <PEER>:<PORT>/autoconfig.pac
http://127.0.0.1:8090/autoconfig.pac
oder
http://192.168.0.167:48002/autoconfig.pac
Es ist keine weitere Konfiguration mehr erforderlich, der Browser merkt Änderungen des Ports automatisch. Wer sich für die Möglichkeiten interessiert, die dieser Mechanismus bietet, lese http://web.archive.org/web/20060424005037/wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html
So ist es z.B. extrem einfach möglich einen Load-Balancer beim Einsatz eines YaCy-Clusters zu bauen.
Die Benutzung dieser Methode wird angeraten um den Wartungsaufwand zu minimieren und um Problemen mit FTP-Server vorzubeugen.
Beispiele
YaCy läuft auf der gleichen Maschine (auf Port 8090). Die Datei wird als Datei proxy.pac im Verzeichnis DATA/HTDOCS/www/ abgelegt. Somit kann im Browser als Autokonfiguration eingestellt werden:
http://127.0.0.1:8090/www/proxy.pac
Folgende Beispiele geben jeweils den Inhalt der proxy.pac wieder.
jeder http-Verkehr über YaCy, sonst direkt
function FindProxyForURL(url, host) { yacy = "PROXY localhost:8090; DIRECT"; direkt = "DIRECT"; url = url.toLowerCase(); host = host.toLowerCase(); ip = myIpAddress(); if (shExpMatch(host,"*:*")) { hostport = host.split(":"); host = hostport[0].toLowerCase(); port = hostport[1].toLowerCase(); }; if (shExpMatch(url,"http:*")) { return yacy; } return direkt; }
jeder Verkehr direkt, nur http://*.yacy über YaCy
function FindProxyForURL(url, host) { yacy = "PROXY localhost:8090; DIRECT"; direkt = "DIRECT"; url = url.toLowerCase(); host = host.toLowerCase(); ip = myIpAddress(); if (shExpMatch(host,"*:*")) { hostport = host.split(":"); host = hostport[0].toLowerCase(); port = hostport[1].toLowerCase(); }; if (shExpMatch(host,"*.yacy")) { return yacy; } return direkt; }
komplexes Beispiel
Hier ein kleines LAN. Hier gibt es die Rechner borg und worf. Auf borg läuft auf 8090 YaCy. Auf worf läuft tor auf Port 9050 und Squid auf Port 3128. Diese Konfiguration gilt dann für alle Rechner im LAN.
function FindProxyForURL(url, host) { squid = "PROXY worf:3128; DIRECT"; yacy = "PROXY borg:8090; PROXY worf:3128; PROXY www-proxy.netcologne.de:8090; DIRECT"; tor = "SOCKS worf:9050; PROXY worf:8000; DIRECT"; netcologne = "PROXY www-proxy.netcologne.de:8090; DIRECT"; direkt = "DIRECT"; url = url.toLowerCase(); host = host.toLowerCase(); ip = myIpAddress(); if (shExpMatch(host,"*:*")) { hostport = host.split(":"); host = hostport[0].toLowerCase(); port = hostport[1].toLowerCase(); }; // yacy über yacy if (shExpMatch(host,"*.yacy")) { return yacy; } // onion über tor if (shExpMatch(host,"*.onion")) { return tor; } // lokales direkt if (shExpMatch(dnsResolve(host),"192.168.0.*")) { return direkt; } // localhost direct if (shExpMatch(dnsResolve(host),"127.0.0.*")) { return direkt; } // alle Multimedia über Proxy if (shExpMatch(url, "*.jpg*")) return squid; if (shExpMatch(url, "*.jpeg*")) return squid; if (shExpMatch(url, "*.gif*")) return squid; if (shExpMatch(url, "*.png*")) return squid; if (shExpMatch(url, "*.class*")) return squid; if (shExpMatch(url, "*.mid*")) return squid; if (shExpMatch(url, "*.swf*")) return squid; if (shExpMatch(url,"http:*")) { return yacy; } if (shExpMatch(url,"ftp:*")) { return netcologne; } return direkt; }