1. Aktuelles
  2. Dashboard
  3. Forum
    1. Unerledigte Themen
  4. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
  5. Community vs. Enterprise
  • Anmelden
  • Registrieren
  • Suche
Dieses Thema
  • Alles
  • Dieses Thema
  • Dieses Forum
  • Artikel
  • Forum
  • Seiten
  • Erweiterte Suche
  1. efw-forum - Endian Firewall Support Forum
  2. Forum
  3. Archiv
  4. Endian Firewall 2.4
  5. SMTP, HTTP, SIP, FTP Proxy Support

proxy.pac Verzeichnis gesucht

  • Bios2001
  • 12. Mai 2011 um 15:02
  • Erledigt
1. offizieller Beitrag
  • Bios2001
    Anfänger
    Beiträge
    28
    • 12. Mai 2011 um 15:02
    • #1

    Hallo Zusammen,
    seit ca. einem Jahr verwende ich die endian FW, jetzt aktuell in der Version 2.4.1. Die Fw läuft als Vmware aus esx 3.5. Alles läuft super zufriedenstellend und performant. Mit Kabeldeutschland komme ich auf Übertragungsraten von über 2 MB/s. Echt cool. Nuur....
    Wenn ich den Proxy aktiviere ist nach ca . einer Woche Feierabend und die ganze Maschine wird träge und träger und so weiter. Also lasse ich den Proxy ausgeschaltet.
    Nun habe ich dieser Anregung http://www.howtoforge.com/tiny-content-f…d-apache-vmware eine weitere Vmware aufgesetzt und zum Laufen gebracht. Seit einer ganzen Weile läuft das System stabil, und nach dem nun die Testphase abgeschlossen ist, möchte ich den Proxy dem ganzen Netzwerk zur Verfügung stellen. Einige Stunden Recherche sind bereits draufgegangen und was ich nun weiß ist folgendes. Moderne Browser können die Proxy Einstellung automatisch lesen. Klappt ja auch über den Efw Built In Proxy. Mit http://wpad/proxy.pac kann ich auch die pac-Datei von der endian runterladen. Nur finde ich die Datei nirgends auf dem System. Es gibt eine ca 12kB große proxy.pac unter ... (bin auf Arbeit und hab den Pfad nicht Kopf), aber die enthält viele Variablen usw. Wo ist die proxy.pac, die ich via Browser runterladen kann????
    Meine Idee ist nämlich, wenn ich die richtige proxy.pac finde, kann ich in der Zeile mit der Ip-Adresse meinen neuen Proxy eintragen und somit bekommen alle Clients den neuen Proxy zugewiesen. Die Alternative wäre die Vorgehensweise über die dhcp Optionen, sind aber nicht bevorzugt.

    Ich hoffe ich konnte meine Idee so halbwegs richtig ausdrücken?

    Viele Grüße
    Thomas

    EFW 2.51 - Community
    Kabel - 32 MBit
    Celeron G530 - 2GB Ram
    ESXi 5.0 - 8GB Ram - 640GB HD
    3 * NIC

  • ffischer
    Moderator
    Reaktionen
    18
    Trophäen
    1
    Artikel
    8
    Beiträge
    2.414
    • 12. Mai 2011 um 17:22
    • Offizieller Beitrag
    • #2

    Hallo,

    es gibt eine wpad.dat und die proxy.pa
    die verweisen aber alle auf die

    Code
    /home/httpd/html/proxy.pac

    Edit:
    Nach Analyse,
    glaube ich das deine WPAD die du brauchst unter

    Code
    /etc/dnsmasq/hosts.d/proxywpad.conf


    ich würde ggf den conf.tmpl abändern da die conf immer neu geschrieben wird mit der conf.tmpl


    gruß Frank

    Endian Authorized Partner

    freaky-media
    Kein Support per PN dafür ist das Forum da.
    Preisanfragen zur Appliance Produkten sind über freaky-media möglich.

    • Nächster offizieller Beitrag
  • Bios2001
    Anfänger
    Beiträge
    28
    • 12. Mai 2011 um 21:48
    • #3

    Hi Frank,
    danke für Deine Antwort.
    17:56 Uhr
    Die proxy.pac ist tatsächlich die

    Code
    /home/httpd/html/proxy.pac


    Leider funktioniert die Umleitung irgendwie doch nicht. Die Datei wird dynamisch erzeugt und zeigt beim runterladen von

    Code
    http://wpad/proxy.pac

    folgenden Inhalt:
    20:37 Uhr

    Letzte Zeilen der Datei proxy.pac auf der Fw:

    Code
    print <<END
            else {
    END
        ;
        if ($ip eq '' || $port eq '' || $any eq 0) {
            print <<END
                    return "PROXY 192.168.0.3:3128;DIRECT";
    END
            ;
        }
        else {
            print <<END
                    return "PROXY $ip:$port; DIRECT";
    END
            ;
        }
        print <<END
            }
    }
    END
        ;
    }
    
    
    my $zone = calculate_zone($ENV{'REMOTE_ADDR'});
    showhttpheaders();
    printpac($zone, get_ip($zone, $ENV{'REMOTE_ADDR'}), get_port($zone), $net_conf{$zone.'_IPS'});
    exit(0);
    Alles anzeigen

    ergeben

    Code
    function FindProxyForURL(url, host)
    {
            if (isPlainHostName(host) || shExpMatch( url, "*192.168.0.254*" ) ) {
                    return "DIRECT";
            }
            else if (host == "127.0.0.1") {
                    return "DIRECT";
            }
            else {
                    return "PROXY 192.168.0.3:3128;DIRECT";
            }
    }
    *********************************************
    Alles anzeigen


    Lt. Wiki und Google sollte das so richtig sein. Das der Proxy funktioniert sehe ich wenn ich die Einstellung "Manuelle Proxy Konfiguration" aktiviere.
    21:10 Uhr
    Die proxy.pac funktioniert auch, wenn man bei der Option Automatische Proxy-Konfigurations-URL statt wpad die Ip-Adresse verwendet. Also ist proxy.pac die schon mal i.O.
    21:31 Uhr
    Die Lösung:
    Ich habe in den der DHCP Konfiguration auf der efw die DHCP-Optionen

    Code
    option wpad code 252 = text;
    option wpad “http://192.168.0.254/wpad.dat”;

    hinzugefügt. Und? Siehe da! Der geht!

    Jetzt kommen noch ein paar Verfeinerungen und dann ist die Welt schön :)

    Viele Grüße
    Thomas

    EFW 2.51 - Community
    Kabel - 32 MBit
    Celeron G530 - 2GB Ram
    ESXi 5.0 - 8GB Ram - 640GB HD
    3 * NIC

  • Bios2001
    Anfänger
    Beiträge
    28
    • 5. Juni 2011 um 11:47
    • #4

    Moin,
    bei meinen Versuchen einen Proxy zu etablieren ist mir leider die originale
    /home/httpd/html/proxy.pac verloren gegangen.
    Kann mir jemand von euch den Inhalt oder die Datei selbst

    Code
    quasi von
    #!/usr/bin/perl -w
    
    
    #
    #        +-----------------------------------------------------------------------------+
    #        | Endian Firewall                                                             |
    #        +-----------------------------------------------------------------------------+
    #        | Copyright (c) 2005-2006 Endian                                              |
    #        |         Endian 
    ------------------------schnipp
    bis Ende bzw. die letzten 
    paar Zeilen
    ------------------------schnapp
    function FindProxyForURL(url, host)
    {
            if (isPlainHostName(host) || shExpMatch( url, "*$ip*" ) ) {
                    return "DIRECT";
            }
            else if (host == "127.0.0.1") {
                    return "DIRECT";
            }
    END
        ;
    
    
        if (-f $custom_include)  {
            include_file($custom_include);  
        }
        my @lines = read_config_file($policyrules);
        my $num = 1;
        my $any = 0;
    
        if ($conf{"PROXY_ENABLED"} eq "on") {
    #         if ($conf{uc($zone) . "_ENABLED"} eq "transparent") {
    #             foreach my $net (split(/,/, $zone_nets)) {
    #                 my ($netaddr, $netmask) = ipv4_network($net);
    #                 $netmask = ipv4_cidr2msk($netmask);
    #                 print <<END
    #         else if (isInNet(host, "$netaddr", "$netmask"))
    #             return "DIRECT";
    # END
    #                 ;
    #             }
    #         }
    
            foreach my $thisline (@lines) {
                chomp($thisline);
                my %info = policy_line($thisline);
                if ($info{"enabled"} ne "on") {
                    next;
                }
                elsif ($info{"src_type"} eq "any") {
                    $any = 1;
                }
                elsif ($info{"src_type"} eq "zone" && uc($info{"src"}) eq uc($zone)) {
                    foreach my $net (split(/,/, $zone_nets)) {
                        my ($netaddr, $netmask) = ipv4_network($net);
                        $netmask = ipv4_cidr2msk($netmask);
                        print <<END
            else if (isInNet(host, "$netaddr", "$netmask") {
                    return "PROXY $ip:$port; DIRECT";
            }
    END
                        ;
                    }
                }
                elsif ($info{"src_type"} eq "ip") {
                    foreach my $net (split(/\|/, $info{"src"})) {
                        if (is_ip($net)) {
                            print <<END
            else if (host == "$net") {
                    return "PROXY $ip:$port; DIRECT";
            }
    END
                            ;
                        }
                        elsif (is_ipandmask($net)) {
                            my ($netaddr, $netmask) = ipv4_network($net);
                            $netmask = ipv4_cidr2msk($netmask);
                            print <<END
            else if (isInNet(host, "$netaddr", "$netmask") {
                    return "PROXY $ip:$port; DIRECT";
            }
    END
                            ;
                        }
                    }
                }
            }
        }
        print <<END
            else {
    END
        ;
        if ($ip eq '' || $port eq '' || $any eq 0) {
            print <<END
                    return "PROXY $ip:$port;DIRECT";
    END
            ;
        }
        else {
            print <<END
                    return "DIRECT";
    END
            ;
        }
        print <<END
            }
    }
    END
        ;
    }
    
    
    my $zone = calculate_zone($ENV{'REMOTE_ADDR'});
    showhttpheaders();
    printpac($zone, get_ip($zone, $ENV{'REMOTE_ADDR'}), get_port($zone), $net_conf{$zone.'_IPS'});
    exit(0);
    Alles anzeigen


    zur Verfügung stellen. Ich habe da irgendwas vergurkt.

    Dannke im vorraus
    Thomas

    EFW 2.51 - Community
    Kabel - 32 MBit
    Celeron G530 - 2GB Ram
    ESXi 5.0 - 8GB Ram - 640GB HD
    3 * NIC

  • Sabine
    Moderator
    Reaktionen
    7
    Trophäen
    1
    Beiträge
    3.411
    • 5. Juni 2011 um 13:24
    • Offizieller Beitrag
    • #5

    Bei mir steht das drin:


    #!/usr/bin/perl -w

    #
    # +-----------------------------------------------------------------------------+
    # | Endian Firewall |
    # +-----------------------------------------------------------------------------+
    # | Copyright (c) 2005-2006 Endian |
    # | Endian GmbH/Srl |
    # | Bergweg 41 Via Monte |
    # | 39057 Eppan/Appiano |
    # | ITALIEN/ITALIA |
    # | info@endian.it |
    # | |
    # | This program is free software; you can redistribute it and/or |
    # | modify it under the terms of the GNU General Public License |
    # | as published by the Free Software Foundation; either version 2 |
    # | of the License, or (at your option) any later version. |
    # | |
    # | This program is distributed in the hope that it will be useful, |
    # | but WITHOUT ANY WARRANTY; without even the implied warranty of |
    # | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
    # | GNU General Public License for more details. |
    # | |
    # | You should have received a copy of the GNU General Public License |
    # | along with this program; if not, write to the Free Software |
    # | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
    # | http://www.fsf.org/ |
    # +-----------------------------------------------------------------------------+
    #

    use strict;
    use CGI();
    use Net::IPv4Addr qw (:all);

    my %netsettings;
    my %net_conf;
    my $swroot = "/var/efw/";

    my $ETHER_SETTINGS = $swroot."ethernet/settings";
    my $routingfile = $swroot."routing/config";
    my $custom_include = $swroot."proxy/proxy.custom.pac";

    my $proxy_conffile = "${swroot}/proxy/settings";
    my $proxy_conffile_default = "/usr/lib/efw/proxy/default/settings";
    my $policyrules = "${swroot}/proxy/policyrules";


    sub showhttpheaders() {
    my $file = $ENV{'SCRIPT_NAME'};
    $file =~ s/^[\/]*//;

    print <<EOF
    Cache-Control: no-cache
    Connection: close
    Content-Type: application/x-ns-proxy-autoconfig
    Content-Disposition: attachement; filename="$file"

    EOF
    ;
    }

    sub readhash($$) {
    my $filename = shift;
    my $hash = shift;
    my ($var, $val);

    open(FILE, $filename) or die "Unable to read file $filename";

    while (<FILE>) {
    chomp;
    ($var, $val) = split /=/, $_, 2;
    if ($var) {
    $val =~ s/^\'//g;
    $val =~ s/\'$//g;
    # Untaint variables read from hash
    $var =~ /([A-Za-z0-9_-]*)/;
    $var = $1;
    $val =~ /([\w\W]*)/;
    $val = $1;
    $hash->{$var} = $val;
    }
    }
    close FILE;
    }

    sub is_valid($) {
    my $line = shift;
    if ($line =~ /(?:(?:[^,]*),){9}/) {
    return 1;
    }
    return 0;
    }

    sub read_config_file($) {
    my $filename = shift;
    my @lines;
    open (FILE, "$filename");
    foreach my $line (<FILE>) {
    chomp($line);
    $line =~ s/[\r\n]//g;
    if (!is_valid($line)) {
    next;
    }
    push(@lines, $line);
    }
    close (FILE);
    return @lines;
    }

    sub read_config_line($$) {
    my $line = shift;
    my $file = shift;
    my @lines = read_config_file($file);
    return $lines[$line];
    }

    sub policy_line($) {
    my $line = shift;
    my %config;
    $config{'valid'} = 0;
    if (! is_valid($line)) {
    return;
    }
    my @temp = split(/,/, $line);
    $config{'enabled'} = $temp[0];
    $config{'policy'} = $temp[1];
    $config{'transparent'} = $temp[2];
    $config{'auth'} = $temp[3];
    $config{'auth_group'} = $temp[4];
    $config{'time_restriction'} = $temp[5];
    $config{'days'} = $temp[6];
    $config{'starthour'} = $temp[7];
    if ($config{'starthour'} eq "") {
    $config{'starthour'} = "00";
    }
    $config{'startminute'} = $temp[8];
    if ($config{'startminute'} eq "") {
    $config{'startminute'} = "00";
    }
    $config{'stophour'} = $temp[9];
    if ($config{'stophour'} eq "") {
    $config{'stophour'} = "24";
    }
    $config{'stopminute'} = $temp[10];
    if ($config{'stopminute'} eq "") {
    $config{'stopminute'} = "00";
    }
    $config{'filtertype'} = $temp[11];
    $config{'src_type'} = $temp[12];
    $config{'src'} = $temp[13];
    $config{'src'} =~ s/&/\|/g;
    $config{'dst_type'} = $temp[14];
    $config{'dst'} = $temp[15];
    $config{'dst'} =~ s/&/\|/g;
    $config{'mimetypes'} = $temp[16];
    $config{'useragents'} = $temp[17];
    $config{'useragents'} =~ s/&/\|/g;
    $config{'valid'} = 1;

    return %config;
    }

    sub read_settings() {
    ## -------------------------------------------------------------
    ## get settings and CGI parameters
    ## -------------------------------------------------------------
    my %conf = ();
    my %default_conf = ();

    if ( -e $proxy_conffile_default ) {
    &readhash( "$proxy_conffile_default", \%default_conf );
    &readhash( "$proxy_conffile_default", \%conf );
    }
    if ( -e $proxy_conffile ) {
    &readhash( "$proxy_conffile", \%conf );
    }
    return \%default_conf, \%conf;
    }

    (my $default_conf_ref, my $conf_ref) = read_settings();
    my %default_conf = %$default_conf_ref;
    my %conf = %$conf_ref;
    readhash($ETHER_SETTINGS, \%net_conf);

    sub get_zone($) {
    my $ip = shift;
    my @zones = ('GREEN', 'BLUE', 'ORANGE');

    return '' if ($ip =~ /^$/);

    foreach my $zone (@zones) {
    if (! $net_conf{$zone.'_IPS'}) {
    next;
    }
    foreach my $net (split(/,/, $net_conf{$zone.'_IPS'})) {
    if (ipv4_in_network($net, "$ip/32")) {
    return $zone;
    }
    }
    }
    return '';
    }

    sub get_port($) {
    my $zone = shift;
    $zone = uc($zone);
    if ($conf{"PROXY_ENABLED"} eq "on") {
    return $conf{'PROXY_PORT'};
    }
    return "";
    }

    sub get_ip($$) {
    my $zone = shift;
    my $ip = shift;
    $zone = uc($zone);
    foreach my $net (split(/,/, $net_conf{$zone.'_IPS'})) {
    if (ipv4_in_network($net, "$ip/32")) {
    my ($ip, $mask) = ipv4_parse($net);
    return $ip;
    }
    }
    return $net_conf{$zone.'_ADDRESS'}
    }

    sub search_route_subnet($) {
    my $ip = shift;

    return '' if (! -e "$routingfile");
    open (F, "$routingfile") || return '';

    foreach my $line (<F>) {
    my @token = split(/,/, $line);
    next if ($token[0] eq 'off');
    next if ($token[2] eq '');
    next if ($token[3] =~ /^UPLINK/);
    my @ipaddr = split(/\//, $token[2]);
    if ($ipaddr[0]) {
    if (ipv4_in_network($ipaddr[0],
    "$ip/32"
    )) {
    close(F);
    return $token[3];
    }
    }
    }

    close(F);
    return '';
    }

    sub calculate_zone($) {
    my $ip = shift;
    my $zone = get_zone($ip);
    return $zone if ($zone !~ /^$/);

    my $gw = search_route_subnet($ip);
    return get_zone($gw);
    }

    sub is_ip {
    my $addr = shift;
    my $withcidr = shift;
    if (! $withcidr) {
    $withcidr = 1;
    }

    if ($addr !~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(?:\/(\d{1,2}))?$/) {
    return 0;
    }

    my @parts = {$1, $2, $3, $4};
    my $cidr = '';
    if ($5) {
    if ($withcidr eq 0) {
    return 0;
    }
    $cidr = $5;
    }
    foreach my $number (@parts) {
    $number = s/\D//;
    if (($number < 0) || ($number > 255)) {
    return 0;
    }
    }
    if ($cidr ne '') {
    if (($cidr < 0) || ($cidr > 32)) {
    return 0;
    }
    }

    return 1;
    }

    sub is_mask {
    my $mask = $_[0];
    # secord part an ip?
    if (&is_ip($mask)) {
    return 1;
    }
    # second part a number?
    if (/^0/) {
    return 0;
    }
    if (!($mask =~ /^\d+$/)) {
    return 0;
    }
    if ($mask >= 0 && $mask <= 32) {
    return 1;
    }
    return 0;
    }

    sub is_ipormask {
    my $ipormask = $_[0];

    # see if it is a IP only.
    if (&is_ip($ipormask)) {
    return 1;
    }
    # split it into number and mask.
    if (!($ipormask =~ /^(.*?)\/(.*?)$/)) {
    return 0;
    }
    my $ip = $1;
    my $mask = $2;
    # first part not a ip?
    if (!(&is_ip($ip))) { return 0; }
    return &is_mask($mask);
    }

    sub is_ipandmask {
    my $ipandmask = $_[0];

    # split it into number and mask.
    if (!($ipandmask =~ /^(.*?)\/(.*?)$/)) {
    return 0;
    }
    my $ip = $1;
    my $mask = $2;
    # first part not a ip?
    if (!(&is_ip($ip, 0))) {
    return 0;
    }
    return &is_mask($mask);
    }

    sub include_file($) {
    my $file = shift;
    open(F, $file);
    print <F>;
    close(F);
    };

    sub printpac($$$$) {
    my $zone = shift;
    my $ip = shift;
    my $port = shift;
    my $zone_nets = shift;

    print <<END
    function FindProxyForURL(url, host)
    {
    if (isPlainHostName(host) || shExpMatch( url, "*$ip*" ) ) {
    return "DIRECT";
    }
    else if (host == "127.0.0.1") {
    return "DIRECT";
    }
    END
    ;

    if (-f $custom_include) {
    include_file($custom_include);
    }
    my @lines = read_config_file($policyrules);
    my $num = 1;
    my $any = 0;

    if ($conf{"PROXY_ENABLED"} eq "on") {
    # if ($conf{uc($zone) . "_ENABLED"} eq "transparent") {
    # foreach my $net (split(/,/, $zone_nets)) {
    # my ($netaddr, $netmask) = ipv4_network($net);
    # $netmask = ipv4_cidr2msk($netmask);
    # print <<END
    # else if (isInNet(host, "$netaddr", "$netmask"))
    # return "DIRECT";
    # END
    # ;
    # }
    # }

    foreach my $thisline (@lines) {
    chomp($thisline);
    my %info = policy_line($thisline);
    if ($info{"enabled"} ne "on") {
    next;
    }
    elsif ($info{"src_type"} eq "any") {
    $any = 1;
    }
    elsif ($info{"src_type"} eq "zone" && uc($info{"src"}) eq uc($zone)) {
    foreach my $net (split(/,/, $zone_nets)) {
    my ($netaddr, $netmask) = ipv4_network($net);
    $netmask = ipv4_cidr2msk($netmask);
    print <<END
    else if (isInNet(host, "$netaddr", "$netmask") {
    return "PROXY $ip:$port; DIRECT";
    }
    END
    ;
    }
    }
    elsif ($info{"src_type"} eq "ip") {
    foreach my $net (split(/\|/, $info{"src"})) {
    if (is_ip($net)) {
    print <<END
    else if (host == "$net") {
    return "PROXY $ip:$port; DIRECT";
    }
    END
    ;
    }
    elsif (is_ipandmask($net)) {
    my ($netaddr, $netmask) = ipv4_network($net);
    $netmask = ipv4_cidr2msk($netmask);
    print <<END
    else if (isInNet(host, "$netaddr", "$netmask") {
    return "PROXY $ip:$port; DIRECT";
    }
    END
    ;
    }
    }
    }
    }
    }
    print <<END
    else {
    END
    ;
    if ($ip eq '' || $port eq '' || $any eq 0) {
    print <<END
    return "DIRECT";
    END
    ;
    }
    else {
    print <<END
    return "PROXY $ip:$port; DIRECT";
    END
    ;
    }
    print <<END
    }
    }
    END
    ;
    }

    my $zone = calculate_zone($ENV{'REMOTE_ADDR'});
    showhttpheaders();
    printpac($zone, get_ip($zone, $ENV{'REMOTE_ADDR'}), get_port($zone), $net_conf{$zone.'_IPS'});
    exit(0);

    EFW Version im Einsatz:
    2 x Endian UTM Enterprise Software Appliance 3.0.5
    1 x Endian Community 3.2.4
    2 x 2.5.1
    8 x 2.2 Final

    • Vorheriger offizieller Beitrag
  • Bios2001
    Anfänger
    Beiträge
    28
    • 9. Juni 2011 um 18:26
    • #6

    Danke Dir.
    Bei der hin und her Editiererei (dolles Wort, genau wie Inkompetenzkompensierungskompetenz) habe ich endlich wieder eine funktionierenden Proxy.pac. Witzig finde ich, dass die Datei trotz ausgeschaltetem Proxy aufrufbar ist.

    viele Grüße
    Thomas

    EFW 2.51 - Community
    Kabel - 32 MBit
    Celeron G530 - 2GB Ram
    ESXi 5.0 - 8GB Ram - 640GB HD
    3 * NIC

Unterstützt von

  1. Datenschutzerklärung
  2. Impressum
Community-Software: WoltLab Suite™