문제

결과로 끔찍하고 끔찍한 오류, 우리는 Apache를 Tomcat에 연결하는 방법을 변경했습니다. 우리는 사용하고있었습니다 mod_jk:

JkMount /path ajp13

이제 우리는 사용하고 있습니다 mod_proxy_ajp:

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

그러나 기능이 있습니다 JkMount 제공되었지만 ProxyPass 그렇지 않습니다 : 파일 유형에서 선택할 수있는 기능. 이로 인해 이미지가 아닌 HTML 파일을 프록시 할 수 없었습니다. 즉, 멋진 빠른 아파치가 정적 인 재료를 제공하고 역동적 인 것들에 대해서만 느린 Tomcat에 의지 할 수있었습니다.

JkMount /*.html ajp13

이것을 달성하는 방법이 있습니까? ProxyPass? 아마도 주변을 사용할 수 있습니다 <Location> 지침이나 그런 것?

도움이 되었습니까?

해결책

사용 proxypassmatch:

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

편집 : 마커스 다우닝의 수정

다른 팁

문제가 아니라이 구성을 사용하기 위해 조심해야 할 사항입니다. Apache mod_proxy를 사용하여 Tomcat에 연결하는 동안 오류 로그가 적당한 부하 하에서 연결이 삭제되었습니다. httpd.conf에 이것을 추가하면 문제가 해결되었습니다.

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

Kmkaplan의 게시물은 정답이지만 오류를주었습니다.

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

지침을 읽도록 변경했을 때 효과가있었습니다.

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

나는 단지 그것을 넣는 것만 가정 할 수있다 $1 포트 번호 바로 옆 8009 혼란 스러웠다.

우리는 다음을 사용하여 Apache가 이미지를 제공하고 합리적인 만료 헤더를 설정할 수 있도록합니다.

<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>

그러나 보시다시피, 우리는 Tomcat 응용 프로그램 외부에 이미지를 저장합니다. 응용 프로그램 내부의 이미지에 대해서도 작동하는지 모르겠습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top