john-doe
Goto Top

Apache Reverse Proxy als Authentifizierungsproxy - Error 401

Hallo Leute

Ich bin zwar hier nicht ganz richtig unter Linux: Apache Server, aber ich denke es passt dennoch am Besten.

So nun zum Problem:
Auf einem Windows Embedded System läuft ein kleiner Webserver für die Webvisualisierung einer SPS, dieser Webserver bietet nahezu keine Möglichkeiten etwas zu konfigurieren.
Nachdem dieses Webinterface nun auch von Extern erreichbar sein muss, ist eine Authentifizierung notwendig.

Also hab ich einen Apache 2.4 installiert und ihn als Reverse-Proxy konfiguriert. Soweit funktioniert auch alles, allerding sobald ich die Basic Authentifizierung aktiviere funktioniert zeigt der Proxy nach richtiger Eingabe von Benutzername und Passwort nur "401 authorization required" wenn ich die apache config ändere kann auch "502 Bad Gateway" hatte ich schon.

Spannenderweise wenn ich auf dem selben reverse-proxy eine andere proxyurl hinterlege funktioniert alles ohne Probleme.

Define SRVROOT "c:\Apache24"
ServerRoot "${SRVROOT}"
Listen 8080

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
LoadModule xml2enc_module modules/mod_xml2enc.so
LoadFile   C:\Apache24\bin\libxml2.dll
LoadModule filter_module modules/mod_filter.so

<IfModule unixd_module>
User daemon
Group daemon

</IfModule>

ServerAdmin support@irgendwer.de

ServerName irgendeinserver

<Directory />


    AllowOverride none
    Require all denied


</Directory>
DocumentRoot "${SRVROOT}/htdocs"

#####
	#ProxyRequests off

	ProxyPreserveHost Off
        ProxyHTMLInterp On
        ProxyPass / http://localhost/
        ProxyPassReverse / http://localhost/
 
        ProxyHTMLURLMap http://localhost /
	ProxyBadHeader Ignore
		
	
        <location />
	
		AuthType Basic
 		AuthName "Bitte Passwort eingeben"
	       	AuthUserFile c:\tmp\pwd
        	AuthBasicProvider file
        	require valid-user
		
 		ProxyPassReverse /
                SetOutputFilter proxy-html
		 
                ProxyHTMLURLMap http://localhost/ /
                RequestHeader    unset  Accept-Encoding
	
        </location>
#####

<Directory "${SRVROOT}/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error.log"
LogLevel info

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access.log" common
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
</IfModule>

<IfModule cgid_module>
</IfModule>

<Directory "${SRVROOT}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

<IfModule proxy_html_module>
Include conf/extra/httpd-proxy-html.conf
</IfModule>

<IfModule deflate_module>
Include conf/extra/httpd-deflate.conf
</IfModule>

<IfModule ssl_module>
#Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-ahssl.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<IfModule http2_module>
    ProtocolsHonorOrder On
    Protocols h2 h2c http/1.1
</IfModule>


hat jemand noch eine Idee was ich versuche könnte bzw. vielleicht sieht jemand wo das Problem liegen könnte.

Danke euch!

LG J.D.

Content-Key: 292643

Url: https://administrator.de/contentid/292643

Printed on: April 25, 2024 at 14:04 o'clock

Member: Dani
Dani Jan 09, 2016 updated at 21:00:12 (UTC)
Goto Top
Moin,
gibt es Anhaltspunkte in den Logfiles von Apache?
Hast du die Möglichkeit die Konfiguration, welche doch etwas länger ist, auf ein Minium (Authentifizierung und ProxyPass) zu reduzieren um sicherzustellen, dass es darn liegt nicht?!
WAs für ein Webserver läuft denn auf dem Windows-System?

Ansonsten würde über Alternativen wie Squid oder Ngnix nachdenken.


Gruß,
Dani
Member: john-doe
john-doe Jan 10, 2016 at 10:33:54 (UTC)
Goto Top
Hi, danke für deine Antwort.

Hab es gerade mit Nginx versucht - gleiche Problem ...
Die Config vom Nginx hab ich wirklich auf ein Minimum gekürzt.
Ohne Auth. funktionierts, mit Auth auf eine andere Seite funktionierts auch, aber mit Auth. auf den Atvise-Webserver funktionierts nicht ...
Hab den Verdacht dass irgend was mit den Header-Daten nicht passt, steig aber nicht durch was wirklich los ist.

Die Logfiles sagen wenig .... zu wenig.

webMI2ADS.exe ist der Atvise-Webserver. Irgend so ein Scada-Ding ...

LG J.D.
Member: Dani
Dani Jan 10, 2016 at 10:39:24 (UTC)
Goto Top
Moin,
poste bitte deine nginx Konfiguration. Da kann ich dir eher helfen, als bei Aapache...


Gruß,
Dani
Member: john-doe
john-doe Jan 10, 2016 at 12:26:36 (UTC)
Goto Top
Hi

Hier die nginx.conf

worker_processes  1;
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       8080;
        server_name  frontend.local;
        location / {
            #root   html;
            #index  index.html index.htm;
            auth_basic "Restricted"; #For Basic Auth  
            auth_basic_user_file c:/tmp/pwd; #For Basic Auth
            include C:/nginx/conf/proxy.conf;
            proxy_pass http://localhost:80;
            
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}


Und hier die proxy.conf

proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;


Danke auf jeden Fall mal dass du dir die Zeit nimmst und versuchst mir zu helfen!!

Lg
Member: Dani
Dani Jan 10, 2016 at 19:34:28 (UTC)
Goto Top
Moin,
versuch es ohne die Header:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

webMI2ADS.exe ist der Atvise-Webserver. Irgend so ein Scada-Ding ...
Leider nicht frei erhältlich. face-confused


Gruß,
Dani
Mitglied: 117455
117455 Jan 10, 2016 at 19:38:47 (UTC)
Goto Top
Läuft der Apache auf einem Windows oder Linux System? Wenn Linux, warum "C:/nginx/conf/proxy.conf;" , müsste es nicht "/etc/nginx/conf/proxy.conf;" heißen?

Wenn windows, dann ist das ja egal (Wenn die Pfade auch so stimmen)
Member: john-doe
john-doe Jan 10, 2016 at 19:58:15 (UTC)
Goto Top
@Dani

Danke, funktioniert trotzdem nicht, es kommt 401 - Authorization required.
Hatte schon die komplette proxy.conf deaktiviert um eine ganz einfache config zu haben.

Das blöde bei dem webMI2ADS-Ding ist, man kann nur die Portnummer ändern und sonst nix was den Webserver betrifft.


@117455
Danke für deine Antwort, es ist ein Windowssystem. Die Pfade stimmen schon so, sonst würde sich der nginx bzw. apache gar nicht starten lassen.

LG. J.D