Reverse Proxy leitet Anfragen nicht weiter

Begonnen von TWART016, 25 Dezember 2017, 18:59:29

Vorheriges Thema - Nächstes Thema

TWART016

Hallo,

ich versuche derzeit einen Reverse Proxy einzurichten. Die Installation des Apache und von Letsencrypt hat funktioniert. Auch erreiche ich die Startwebseite. Ich möchte jedoch alle anrufen zu http://localhost:8083/fhem oder einer anderen IP weiterleiten. Jedoch funktioniert das nicht.

So sieht die .conf aus
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName ****.org

    ServerAdmin ****.de
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/****.org.error.log
    CustomLog ${APACHE_LOG_DIR}/****.org.access.log combined

    SSLCertificateFile /etc/letsencrypt/live/****.org/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/****.org/privkey.pem

    Include /etc/letsencrypt/options-ssl-apache.conf

    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    <Location /fhem>
        ProxyPass http://localhost:8083/fhem
        ProxyPassReverse http://localhost:8083/fhem
    </Location>

    <Directory />
        RedirectPermanent / /fhem
    </Directory>

    <Proxy *>
        AuthType Basic
        AuthName "Password for FHEM Required"
        AuthUserFile /etc/fhem-htpasswd
        Require valid-user
        Order deny,allow
        Allow from all
    </Proxy>
</VirtualHost>
</IfModule>


Auch das mit /permanent funktioniert nicht. Die Anfragen werden nicht an /fhem weitergeleitet sondern bleiben beim root Verzeichnis.


Gruß
TWART016

TWART016


Wernieman

Als ich es noch mit dem Apache laufen hatte, war es wie folgt eingerichtet:
ProxyRequests Off
ProxyVia On
RewriteEngine on
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1

ProxyPass /fhem http://localhost:8083/fhem
ProxyPassReverse /fhem http://localhost:8083/fhem


Dein ProxyPass sieht nicht sauber aus, da das Dir fehlt
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

TWART016

Unter /fhem stehen die Einträge bei mit Proxypass. Trage ich den Parameter /fhem in die Zeile mit ein, startet der Apache nicht mehr.

Wie sieht denn keine komplette conf Datei aus?

Seltsam ist, die Standardseite wird aufgerufen. Nur jede Änderung an meiner eigenen Datei bleibt ohne Wirkung.

Wernieman

die Standardseite wird aufgerufen
Wie meinst Du?
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

TWART016

Es öffnet sich die "Apache2 Ubuntu Default Page" und nicht wie konfiguriert automatisch mit Parameter /fhem

/fhem läuft in einen Timeout.
Fehler: Netzwerk-Zeitüberschreitung

Auch die Authentication Abfrage erscheint nicht.

Wernieman

Hast Du mal auf der Maschine selber versucht fhem zu erreichen?

also z.B.
wget http://localhost:8083/fhem
w3mhttp://localhost:8083/fhem
curl http://localhost:8083/fhem

beliebiger anderen Shell-Browser  eben so möglich (lynx etc)
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

TWART016

Über wget und die Remote Adresse wird mir zumindest der HTML Code von FHEM angezeigt.

Wernieman

Wenn de Zugriff über /fhem in ein TimeOut läuft, aber die gleiche Maschine es lokal erreichen kann, stehe ich auf dem Schlauch ... nur wie geschrieben, habe (aus anderen Gründen) den Proxy ausgelagert und verwende einen nginx

Meine alte Config hatte ich zu "/etc/apache2/conf-enabled/fhem.conf" ausgelagert und dort:

#<Location /fhem>
#       AuthType Basic
#       AuthName "Beschraenkter Zugriff! Intranet!"
#       AuthBasicProvider file
#       AuthUserFile /var/www/passwd/htpasswd
#       Require user xxxx
#
#       Order allow,deny
#       Allow from all
#       Satisfy any
#       Require all granted
#</Location>
ProxyPass /fhem http://127.0.0.1:8083/fhem
ProxyPassReverse /fhem http://127.0.0.1:8083/fhem

# vim: ts=4 filetype=apache


- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

Patrik.S

Ist im Apache überhaupt das proxy_module enabled und für die Authentication das auth_basic_module?
Zu prüfen mit apachectl -M

Loaded Modules:
......
auth_basic_module (shared)
......
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
.....
proxy_module (shared)
proxy_connect_module (shared)
proxy_html_module (shared)
proxy_http_module (shared)
....
ssl_module (shared)
....


In der mods-enabled/proxy.conf (sym. Link auf ../mods-available/proxy.conf) stehen bei mir beide Anteile drinnen

<IfModule mod_proxy.c>
        ProxyPass "/fhem" "http://localhost:8083/fhem"
        ProxyPassReverse "/fhem" "http://localhost:8083/fhem"

.....
<Location /fhem>
                AuthType Basic
                AuthName "Der ServerName order sonst irgendein Hinweis"
                AuthBasicProvider file
                AuthUserFile "passwd_file"
                Require valid-user
</Location>
.....
</IfModule>


Beim AuthUserFile ohne absoluten Pfad muss das "passwd_file" dann direkt unter /etc/apache2/ liegen
Darin enthalten die User mit verschlüsseltem PW.

Und weil man es nicht oft genug schreiben kann, in der ssl.conf dann mind. diese Einstellungen vornehmen

        SSLCipherSuite HIGH:!RC4:!aNULL:!eNULL

        # Zur Verhinderungg einer Downgrade Attacke.
        # Der Server entscheidet welche CipherSuite genutzt werden soll
        SSLHonorCipherOrder on

        # Nur TLSv1.2 ist erlaubt
        SSLProtocol -ALL +TLSv1.2


TWART016

Zitat von: Patrik.S am 17 Januar 2018, 21:52:57
Ist im Apache überhaupt das proxy_module enabled und für die Authentication das auth_basic_module?
Zu prüfen mit apachectl -M
Das ist aktiviert
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
proxy_module (shared)
proxy_html_module (shared)
proxy_http_module (shared)
rewrite_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)



In mods-enabled habe ich bisher noch nichts bearbeitet? Wird das dort zwingend benötigt?

Ich habe was eigenes in sites-available angelegt.

Zitat von: Patrik.S am 17 Januar 2018, 21:52:57
Und weil man es nicht oft genug schreiben kann, in der ssl.conf dann mind. diese Einstellungen vornehmen
Ich habe SSLProtocol all -SSLv3 durch SSLProtocol -ALL +TLSv1.2 ersetzt, trotzdem gleiches Verhalten




Patrik.S

Man kann auch alle Einstellungen in einer Datei vornehmen, der Apache verstreut aber die Konfigurationen über viele Dateien, die zu einzelnen Modulen gehöhren.
Im Verzeichnisn ./mods-enabled sieht man nur einen symbolischen Link auf Dateien nach ../mods-available/
Also editiert man eingentlich die Dateien in mods-available, diese werden aber nur gelesen und genutzt, wenn das Modul eingeschaltet ist, eben "mods-enabled".

ZitatÜber wget und die Remote Adresse wird mir zumindest der HTML Code von FHEM angezeigt.
Wie ist das eigentlich zu verstehen?
Ein wget http://localhost:8083/fhem Lokal auf dem Server ist etwas anderes als ein wget Zugriff auf ein Remotesystem wget http://192.1......:8083/fhem

Ist in FHEM zufälligerweise selbst auch eine Passwortabfrage konfiguriert?
Lauscht FHEM nur auf localhost und ist somit nur auf dem Server erreichbar?

"define WEB FHEMWEB 8083 global"  vs.  "define WEB FHEMWEB 8083"
"attr WEB HTTPS 1" NICHT gesetzt?
"attr WEB basicAuth ......." NICHT gesetzt?



Wenn das alles nichts hilft, mal das Loglevel hochschrauben und reingucken.


OT:
Das SSL Protokoll Thema ist so zu verstehen:
SSLProtocol all -SSLv3          === Es sind ALLE Protokole erlaubt, die beim kompilieren vorhanden und eingeschaltet sind, aus dieser Liste wird dann nur das SSLv3 entfernt ==> Am Ende ist hier TLSv1.0 TLSv1.1 und TLSv1.2 erlaubt (Wenn OpenSSL nicht anders kompiliert wurde)
SSLProtocol -ALL +TLSv1.2   === Es ist NICHTS erlaubt (Minus "-"), nur TLSv1.2 wird als einziges explizit erlaubt (Plus "+") ==> Am Ende ist nur TLSv1.2 erlaubt


TWART016

Zitat von: Patrik.S am 18 Januar 2018, 20:38:46
Wie ist das eigentlich zu verstehen?
Über wget wird bei mir eine Datei erstellt mit Namen fhem. In der Datei steht der HTML Code.

Zitat von: Patrik.S am 18 Januar 2018, 20:38:46
Ein wget http://localhost:8083/fhem Lokal auf dem Server ist etwas anderes als ein wget Zugriff auf ein Remotesystem wget http://192.1......:8083/fhem
Beides geht bei mir. Ich habe FHEM auf dem gleichen Server und einem anderen laufen.

Zitat von: Patrik.S am 18 Januar 2018, 20:38:46
Ist in FHEM zufälligerweise selbst auch eine Passwortabfrage konfiguriert?
Lauscht FHEM nur auf localhost und ist somit nur auf dem Server erreichbar?

"define WEB FHEMWEB 8083 global"  vs.  "define WEB FHEMWEB 8083"
"attr WEB HTTPS 1" NICHT gesetzt?
"attr WEB basicAuth ......." NICHT gesetzt?
Ist alles nicht gesetzt. Auch WEB ist 8083 global


Zitat von: Patrik.S am 18 Januar 2018, 20:38:46
Wenn das alles nichts hilft, mal das Loglevel hochschrauben und reingucken.
Meinst du verbose WEB auf 5?

Patrik.S

Mit Loglevel hochschrauben meinte ich den Apache Server: "LogLevel debug"

Das wget bei die die Daten bekommt und diese in eine Datei schreibt hatte ich schon verstanden, es geht hier um deine Aussage
Zitatwget und die Remote Adresse
Denn ein wget http://localhost:8083/fhem ist etwas völlig anderes als ein wget http://remote_ip_adresse:8083/fhem

ZitatWEB ist 8083 global
Ja kann man machen, aber warum dann einen Apache davorschalten, wenn man es im lokalen Netz auch direkt erreichen kann?

Lass mal das Script von dieser Seite laufen, es sammelt alle Konfigurationen zusammen
https://benincampus.blogspot.de/2015/10/show-complete-apache-config-file.html

Je nach System kann die Erste Zeile auch ruhig mit Python 3 laufen, damit funktioniert es auch.
Nur eine der drei Zeilen aussuchen:
#!/usr/bin/python
#!/usr/bin/python3.5
#!/usr/bin/python2.7


Das Ergebnis zeigt dann die gesamte Konfiguration aus allen Include Dateien.

Dein Setup ist nirgendwo beschrieben.
1. wo läuft der Apache?
2. wo läuft FHEM?
3. Betriebssystem wo der Apache läuft?
4. ist da drauf die Firewall eingeschaltet?  iptables --list


Bevor Du die dann hier aber postet, unbedingt die Sensitiven Daten UNKENNTLICH machen!!!! (Passwort des SSL Private Key, etc ....)

TWART016

Zitat von: Patrik.S am 19 Januar 2018, 16:01:41
Mit Loglevel hochschrauben meinte ich den Apache Server: "LogLevel debug"
Mit debug sieht es das Apache Error Log so aus.

[Sat Jan 20 21:27:20.831453 2018] [ssl:info] [pid 1133:tid 140502718732160] AH01914: Configuring server fqdn:443 for SSL protocol
[Sat Jan 20 21:27:20.831698 2018] [ssl:debug] [pid 1133:tid 140502718732160] ssl_engine_init.c(392): AH01893: Configuring TLS extension handling
[Sat Jan 20 21:27:20.837181 2018] [ssl:debug] [pid 1133:tid 140502718732160] ssl_util_ssl.c(443): AH02412: [fqdn:443] Cert matches for name 'fqdn' [subject: CN=fqdn / issuer: CN=Let's Encrypt Au$
[Sat Jan 20 21:27:20.837194 2018] [ssl:info] [pid 1133:tid 140502718732160] AH02568: Certificate and private key fqdn:443:0 configured from /etc/letsencrypt/live/fqdn/fullchain.pem and /etc/letsencrypt/live/t$
[Sat Jan 20 21:27:20.861725 2018] [ssl:info] [pid 1134:tid 140502718732160] AH01914: Configuring server fqdn:443 for SSL protocol
[Sat Jan 20 21:27:20.865182 2018] [ssl:debug] [pid 1134:tid 140502718732160] ssl_engine_init.c(392): AH01893: Configuring TLS extension handling
[Sat Jan 20 21:27:20.868106 2018] [ssl:debug] [pid 1134:tid 140502718732160] ssl_util_ssl.c(443): AH02412: [fqdn:443] Cert matches for name 'fqdn' [subject: CN=fqdn / issuer: CN=Let's Encrypt Au$
[Sat Jan 20 21:27:20.868119 2018] [ssl:info] [pid 1134:tid 140502718732160] AH02568: Certificate and private key fqdn:443:0 configured from /etc/letsencrypt/live/fqdn/fullchain.pem and /etc/letsencrypt/live/t$
[Sat Jan 20 21:27:20.871901 2018] [proxy:debug] [pid 1137:tid 140502718732160] proxy_util.c(1790): AH00925: initializing worker http://localhost:8083/fhem shared
[Sat Jan 20 21:27:20.871907 2018] [proxy:debug] [pid 1137:tid 140502718732160] proxy_util.c(1832): AH00927: initializing worker http://localhost:8083/fhem local
[Sat Jan 20 21:27:20.871913 2018] [proxy:debug] [pid 1137:tid 140502718732160] proxy_util.c(1867): AH00930: initialized pool in child 1137 for (localhost) min=0 max=25 smax=25
[Sat Jan 20 21:27:20.874280 2018] [proxy:debug] [pid 1138:tid 140502718732160] proxy_util.c(1790): AH00925: initializing worker http://localhost:8083/fhem shared
[Sat Jan 20 21:27:20.874287 2018] [proxy:debug] [pid 1138:tid 140502718732160] proxy_util.c(1832): AH00927: initializing worker http://localhost:8083/fhem local
[Sat Jan 20 21:27:20.874296 2018] [proxy:debug] [pid 1138:tid 140502718732160] proxy_util.c(1867): AH00930: initialized pool in child 1138 for (localhost) min=0 max=25 smax=25
[Sat Jan 20 21:31:50.051579 2018] [ssl:info] [pid 1364:tid 140675369101184] AH01914: Configuring server fqdn:443 for SSL protocol
[Sat Jan 20 21:31:50.051785 2018] [ssl:debug] [pid 1364:tid 140675369101184] ssl_engine_init.c(392): AH01893: Configuring TLS extension handling
[Sat Jan 20 21:31:50.052030 2018] [ssl:debug] [pid 1364:tid 140675369101184] ssl_util_ssl.c(443): AH02412: [fqdn:443] Cert matches for name 'fqdn' [subject: CN=fqdn / issuer: CN=Let's Encrypt Au$
[Sat Jan 20 21:31:50.052038 2018] [ssl:info] [pid 1364:tid 140675369101184] AH02568: Certificate and private key fqdn:443:0 configured from /etc/letsencrypt/live/fqdn/fullchain.pem and /etc/letsencrypt/live/t$
[Sat Jan 20 21:31:50.062372 2018] [ssl:info] [pid 1365:tid 140675369101184] AH01914: Configuring server fqdn:443 for SSL protocol
[Sat Jan 20 21:31:50.062573 2018] [ssl:debug] [pid 1365:tid 140675369101184] ssl_engine_init.c(392): AH01893: Configuring TLS extension handling
[Sat Jan 20 21:31:50.062761 2018] [ssl:debug] [pid 1365:tid 140675369101184] ssl_util_ssl.c(443): AH02412: [fqdn:443] Cert matches for name 'fqdn' [subject: CN=fqdn / issuer: CN=Let's Encrypt Au$
[Sat Jan 20 21:31:50.062766 2018] [ssl:info] [pid 1365:tid 140675369101184] AH02568: Certificate and private key fqdn:443:0 configured from /etc/letsencrypt/live/fqdn/fullchain.pem and /etc/letsencrypt/live/t$
[Sat Jan 20 21:31:50.064111 2018] [proxy:debug] [pid 1369:tid 140675369101184] proxy_util.c(1790): AH00925: initializing worker http://localhost:8083/fhem shared
[Sat Jan 20 21:31:50.064118 2018] [proxy:debug] [pid 1369:tid 140675369101184] proxy_util.c(1832): AH00927: initializing worker http://localhost:8083/fhem local
[Sat Jan 20 21:31:50.064129 2018] [proxy:debug] [pid 1369:tid 140675369101184] proxy_util.c(1867): AH00930: initialized pool in child 1369 for (localhost) min=0 max=25 smax=25
[Sat Jan 20 21:31:50.064457 2018] [proxy:debug] [pid 1368:tid 140675369101184] proxy_util.c(1790): AH00925: initializing worker http://localhost:8083/fhem shared
[Sat Jan 20 21:31:50.064463 2018] [proxy:debug] [pid 1368:tid 140675369101184] proxy_util.c(1832): AH00927: initializing worker http://localhost:8083/fhem local
[Sat Jan 20 21:31:50.064474 2018] [proxy:debug] [pid 1368:tid 140675369101184] proxy_util.c(1867): AH00930: initialized pool in child 1368 for (localhost) min=0 max=25 smax=25



Zitat von: Patrik.S am 19 Januar 2018, 16:01:41
Lass mal das Script von dieser Seite laufen, es sammelt alle Konfigurationen zusammen
https://benincampus.blogspot.de/2015/10/show-complete-apache-config-file.html
Ich hoffe, ich habe alle Daten anonymisiert
https://pastebin.com/LnTn5Ki6

Zitat von: Patrik.S am 19 Januar 2018, 16:01:41
Dein Setup ist nirgendwo beschrieben.
1. wo läuft der Apache?
2. wo läuft FHEM?
3. Betriebssystem wo der Apache läuft?
4. ist da drauf die Firewall eingeschaltet?  iptables --list
Ziel ist es, einen Reverse Proxy zu haben, um von extern u.a. auf FHEM zugreifen zu können. Ob der Reverse Proxy auf dem FHEM System laufen wird weiß ich derzeit noch nicht.
Derzeit habe ich einen FHEM auf einem System und den Reverse Proxy auf einem andere System. Alle Server sind Ubuntu.
Der Reverse Proxy hat zu Testzwecken ebenfalls eine FHEM Installation, um Kommunikationsprobleme nur mit anderen Servern auszuschließen.
Die Firewall ist überall aus.
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination