Der Apache-Proxy-Pass funktioniert nicht mit HTTPS

Der Apache-Proxy-Pass funktioniert nicht mit HTTPS

Ich möchte einen bestimmten Unterpfad zu einer Backend-Anwendung umleiten, die auf Port 19011 läuft. Meine Konfigurationsdatei ( /etc/apache2/sites-available/my_domain.conf) sieht folgendermaßen aus:

<VirtualHost *:80>
    ServerName my_domain
    DocumentRoot /var/www/my_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ProxyPass /my_subpath/ http://localhost:19011/
    ProxyPassReverse /my_subpath/ http://localhost:19011/
</VirtualHost>

<VirtualHost *:443>
    SSLEngine On
    SSLProxyEngine On
    SSLCertificateFile /etc/letsencrypt/live/my_domain/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/my_domain/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    
    ServerName my_domain
    DocumentRoot /var/www/my_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ProxyPass /my_subpath/ http://localhost:19011/
    ProxyPassReverse /my_subpath/ http://localhost:19011/
</VirtualHost>

Diese Konfiguration funktioniert mit HTTP, aber nicht mit HTTPS:

  • http://my_domain/my_subpathgeht wie vorgesehen zur Backend-App, während
  • https://my_domain/my_subpathgibt 404 zurück

Ich bin ein Apache-Neuling und weiß daher nicht, warum das nicht funktioniert. Ich sehe auch keine Fehler in den Apache-Protokollen. Was fehlt mir in der Conf-Datei?

Versionen:

  • Apache: 2.4.29
  • Betriebssystem: Ubuntu 18.04.5

Antwort1

Es stellte sich heraus, dass mit meiner Conf-Datei alles in Ordnung war. Es gab eine weitere Conf-Datei namens my_domain-le-ssl.conf, /etc/apache2/sites-availabledie automatisch erstellt wurde, nachdem ich das SSL-Zertifikat mit Letsencrypt erstellt hatte. Diese Conf-Datei enthielt auch einen virtuellen Host für Port 443, und Apache verwendete diesen, um SSL-Anfragen zu bedienen.

Führen Sie im Zweifelsfall das Programm aus, sudo apachectl -Sum die Konfiguration Ihres aktiven virtuellen Hosts anzuzeigen. In meinem Fall wurde etwa Folgendes zurückgegeben:

*:80 my_domain (/etc/apache2/sites-enabled/my_domain.conf:1)
*:443 my_domain (/etc/apache2/sites-enabled/my_domain-le-ssl.conf:2)
*:443 my_domain (/etc/apache2/sites-enabled/my_domain.conf:10)

verwandte Informationen