[gelöst] Apache Authentication Proxy nach Wikibeitrag funzt nicht

Begonnen von maddinthebrain, 08 Juni 2018, 08:36:52

Vorheriges Thema - Nächstes Thema

a-p-s

Hallo,

also ich habe gerade eben bei meiner Konfiguration nachgeschaut. Den Hauptunterschied, den ich sehe, ist, dass ich für bestimmte Dateien den DEFLATE-Filter aktiviert habe (ausgehend)


# Enables outgoing compression for specific file types
<IfModule mod_deflate.c>
<FilesMatch ".*\.(html|htm|shtml|php|css|js|xml|log|txt|bmp|ttf|otf|eot|svg)$">
   SetOutputFilter DEFLATE
</FilesMatch>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml text/x-component
    AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
</IfModule>


Das habe ich im übergeordneten VirtualHost eingefügt.

Mit der Websockets-Unterstützung sieht meine Location-Direktive wie folgt aus:


<Location /fhem>

RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /fhem(.*)       ws://$url$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /fhem(.*)       http://$url$1 [P,L]

# ProxyPass/ProxyPassReverse leitet HTTP requests auf eine andere URL um
ProxyPass http://$url
ProxyPassReverse http://$url

# ProxyHTMLURLMap passt Links im HTML/JavaScript Source an
ProxyHTMLURLMap /        /fhem/
ProxyHTMLURLMap /fhem/   /fhem/

Order deny,allow
Allow from all
</Location>


Authentifizierung ist wie angegeben. Hinzufügen ist, dass da in der Konfiguration noch einiges SSL-Bezogenes bei mir ist und die Let's Encrypt-Unterstützung für die Validierung.

Vielleicht hilft das.

Grüße,
a-p-s


maddinthebrain

Ok, das werde ich probieren.

Was das $url$1 ? Ist das eine Variable? Wie und wo ist die definiert?

Grüße Martin
Viele Grüße
Martin

Futro mit Proxmox und Debian: FHEM, Signalduino 433MHz & 868MHz, MAX!, WeeWX, FHEM2FHEM,
Raspi 4 mit ConBee mit deCONZ und Phoscon für ZigBee Aktoren und Sensoren

a-p-s

Hallo,

ah, vergessen. Da ich meine Konfiguration (mit noch zig anderen Dingen, die da gehostet sind) mit mod_macro strukturiert habe, ist da noch die Variable drin.

Ersetze einfach $url (und nur das - das bei den Rewrite-Regeln nachfolgende $1 muss bleiben) durch die URL zu deinem FHEM-System (mit /fhem, aber ohne nachfolgenden Slash).

Grüße,
a-p-s

Zitat von: maddinthebrain am 11 Juni 2018, 13:45:19
Ok, das werde ich probieren.

Was das $url$1 ? Ist das eine Variable? Wie und wo ist die definiert?

Grüße Martin

maddinthebrain

#18
@a-p-s: Also es gibt Fortschritte: Nun funktionieren auch die SVG-Plots.

Jedoch was immer noch nicht geht, ist das CSS, lokale im FHEM Ordner abgelegte Bilder, JS geht auch nicht... Ich habe mal ein paar Screenshots angehängt. Der erste wie es über den Apache aussieht. Die Symbole ewig groß. Text in Times New Roman... Und einen wie die Seite eigentlich aussehen soll (lokal aufgerufen). Also ist grad schwierig.

Ich poste jetzt mal die virtualhost conf Datei:

  GNU nano 2.2.6                 Datei: nextcloud-ssl.conf                               Verändert

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        <IfModule mod_headers.c>
              Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; pre$
        </IfModule>
                ServerName #############.net
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/#############.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/#############.net/privkey.pem

# Enables outgoing compression for specific file types
        <IfModule mod_deflate.c>
                <FilesMatch ".*\.(html|htm|shtml|php|css|js|xml|log|txt|bmp|ttf|otf|eot|svg)$">
                   SetOutputFilter DEFLATE
                </FilesMatch>
            AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
            AddOutputFilterByType DEFLATE application/rss+xml
            AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml text/x-com$
            AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-java$
        </IfModule>

</VirtualHost>


Die fhem.conf ist nun diese:

<Location /fhem>

  RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /fhem(.*)       ws://localhost:8083/fhem$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /fhem(.*)       http://localhost:8083/fhem$1 [P,L]
 
  # ProxyPass/ProxyPassReverse leitet HTTP requests auf eine andere URL um
  ProxyPass "http://localhost:8083/fhem"
  ProxyPassReverse "http://localhost:8083/fhem"
  ProxyHTMLEnable On
  # ProxyRequests Off
  # RequestHeader unset Accept-Encoding

  SetOutputFilter INFLATE;proxy-html;DEFLATE

  # ProxyHTMLURLMap passt Links im HTML/JavaScript Source an
  ProxyHTMLURLMap / /fhem/
  ProxyHTMLURLMap /fhem/ /fhem/

  AuthType Basic
  AuthName "Password Required"
  AuthUserFile /etc/fhem-htpasswd
  Require valid-user
  Order deny,allow
  Allow from all

</Location>


Die Hoffnung stirbt zuletzt...

EDIT: Also jetzt geht es. Was war die Lösung? Die beiden Einträge von ProxyHTMLURLMap auskommentiert und es funktioniert. Wie kam ich drauf? Im HTML-Code stand halt in den Links etwas oft /fhem/fhem/fhem.... Da dachte ich, ich kommentiere das mal aus. Und siehe da, schon geht's!

Grüße Martin
Viele Grüße
Martin

Futro mit Proxmox und Debian: FHEM, Signalduino 433MHz & 868MHz, MAX!, WeeWX, FHEM2FHEM,
Raspi 4 mit ConBee mit deCONZ und Phoscon für ZigBee Aktoren und Sensoren