Frage

Als Ergebnis der schreckliche, schreckliche Fehler , wir ve verändert, wie wir Apache Tomcat verbinden. Wir wurden mit mod_jk:

JkMount /path ajp13

Jetzt verwenden wir mod_proxy_ajp:

ProxyPass /path ajp://localhost:8009/path
ProxyPassReverse /path ajp://localhost:8009/path

Allerdings gibt es eine Funktion, die angeboten JkMount aber ProxyPass nicht: die Fähigkeit, auf Dateitypen auszuwählen. Dies machte es möglich, Proxy-HTML-Dateien, aber keine Bilder - in anderen Worten, die schön schnell Apache dient die statischen Sachen zu lassen, und nur für das dynamische Zeug zum langsamen Tomcat greifen

.
JkMount /*.html ajp13

Gibt es eine Möglichkeit, dies zu erreichen mit ProxyPass? Möglicherweise eine umgebende <Location> Richtlinie oder so etwas mit?

War es hilfreich?

Lösung

Verwenden Sie ProxyPassMatch :

ProxyPassMatch ^/(path/.*\.html)$ ajp://localhost:8009/$1

Editiert: Marcus Downing Korrektur

Andere Tipps

Nicht Ihr Problem, aber etwas zu achten gilt diese Konfiguration verwenden. Während Apache mod_proxy mit meinem Fehlerprotokoll zeigte fällt tomcat Verbindungen unter mäßiger Last zu verbinden. Addiert man diese zu httpd.conf meine Probleme gelöst.

SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1

kmkaplan die Post ist die richtige Antwort, aber es gab mir den Fehler:

Syntax error on line 32 of .../httpd-vhosts.conf:
ProxyPass Unable to parse URL

Es hat funktioniert, wenn ich die Richtlinie geändert zu lesen:

ProxyPathMatch ^/(path/.*\.html)$ ajp://localhost:8009/$1

Ich kann nur annehmen, dass die $1 direkt neben der Portnummer 8009 setzt es war verwirrend.

Wir verwenden die folgende Apache Bilder dienen zu lassen, und stellen Sie vernünftig abläuft Header:

<Virtualhost *:80>
    ServerName domain.com
    ServerAlias *.domain.com

    Alias /img/ /var/www/domain/img/
    <Directory /var/www/domain/img/>
        ExpiresActive On
        ExpiresByType image/gif "access plus 1 months"
        ExpiresByType image/jpg "access plus 1 months"
        ExpiresByType image/jpeg "access plus 1 months"
        ExpiresByType image/png "access plus 1 months"
        ExpiresByType image/x-icon "access plus 1 months"
        ExpiresByType image/ico "access plus 1 months"
        # This will prevent apache from having to check for a .htaccess file on each request.
        AllowOverride None
        # Allow symlinks. Otherwise, apache will make a separate call on each filename to ensure it is not a symlink.
        Options +FollowSymLinks -SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    # Prevent domain.com/img from being served by Tomcat
    ProxyPass /img !

    # Pass all other requests to Tomcat
    ProxyPass / ajp://localhost:8009/

    # 1. Note that usually no ProxyPassReverse directive is necessary. The AJP request includes
    #    the original host header given to the proxy, and the application server can be expected to
    #    generate self-referential headers relative to this host, so no rewriting is necessary. 
    # 2. If you still want to use it, read this first:
    #    http://www.humboldt.co.uk/2009/02/the-mystery-of-proxypassreverse.html
    # ProxyPassReverse / http://domain.com/
</Virtualhost>

Doch wie Sie sehen können, speichern wir Bilder außerhalb unserer Tomcat-Anwendung. Ich weiß nicht, ob es für Bilder in der Anwendung funktioniert auch.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top