커넥터를 사용하여 Apache 웹 서버를 통해 Tomcat에 액세스하고 싶습니다. 나는 문서
에 충실했다 : http://tomcat.apache.org/connectors-doc/generic_howto/quick.html Debian- (Squeeze) -System에서 사용되는 디렉토리 구조와 일치하도록 약간 수정했습니다.
그래서 /etc/apache2/httpd.conf에 다음을 추가했습니다.
# Load mod_jk module
# Update this path to match your modules location
#LoadModule jk_module libexec/mod_jk.so
# Declare the module for <IfModule directive> (remove this line on Apache 2.x)
#AddModule mod_jk.c
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /tomcat7/* worker1
패키지 시스템 (libapache2-mod-jk)을 통해 mod_jk를 설치 한 후에 이미 발생했기 때문에 모듈로드를 주석 처리했습니다.
내 workers.properties는 다음과 같습니다.
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
Tomcat 7은 Squeeze의 패키지가 아니기 때문에 Apache의 아카이브에서 직접 설치됩니다. Tomcat 7은 자체 포트 (8180, 패키지 시스템의 tomcat6과 충돌하지 않음)에서 실행 중이며 연결할 수 있습니다. 내가 이해하는 한, 이제 http : // host / tomcat7 /으로 Tomcat 사이트를 볼 수 있습니다 . 그러나 대신 404를 얻습니다. 뭐가 잘못 되었 니?
quanta가 로그 수준을 디버그로 설정하도록 암시 한 후 (감사합니다) mod_jk.log에서 다음 오류 메시지를 발견했습니다. / ‘. 나는 그것을 검색하고 http://old.nabble.com/mod_jk%2C-missing-uri-map-td23984359.html을 발견했다.
따라서 httpd.conf에 설정된 옵션은 VirtualHosts에서 사용되지 않았습니다. 내 VirtualHost에 ‘JkMountCopy On’을 추가하고 먼저 httpd 404 대신 Tomcat 404를 얻었습니다. 여기서 문제는, 마운트 된 것과 똑같은 URI에 액세스하려고 시도하므로 내 경우에는 / tomcat7입니다. 대신 webapp의 이름을 마운트로 사용했는데 모든 것이 좋습니다.
답변
다음을 확인하십시오.
- 당신은 뒤에 슬래시 입력 에 http : // 호스트 / tomcat7 / ,하지
에 http : // 호스트 / tomcat7 . -
다음의 포트 8009에서 AJP 1.3 커넥터 청취가 있습니다
server.xml
.<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
그래도 작동하지 않으면 디버그를 켜고를 참조하십시오 mod_jk.log
.
편집하다:
사용하는 경우 :
JkMount /tomcat7/* worker1
http : // host / tomcat7을 통해 액세스 하면 Apache 404 오류가 발생합니다.
원하는 JkMount
가상 호스트 섹션에서 지정할 수 있습니다 .
<VirtualHost *:80>
ServerName xx
ServerAdmin xx
JkMount /tomcat7 worker1
JkMount /tomcat7/* worker1
</VirtualHost>
답변
나는 같은 문제가 있었다. 해결책은로 변경 JkMount /tomcat7* worker1
하는 것 JkMount /your-servlet-app* worker1
입니다. JkMount
원하는만큼 가질 수 있습니다 .
예를 들어을 추가 JkMount /manager* worker1
하면 액세스 할 수 있습니다.http://host/manager/html
AJP와 http를 모두 시도한 후에이 문제를 파악했습니다. 내 로그인 로그는 다음과 같습니다./var/log/tomcat7/localhost_access_log.txt
10.215.22.132 - - [04/Mar/2016:13:14:39 +0800] "GET /tomcat-demo/manager/ HTTP/1.1" 404 1009
10.215.22.132 - - [04/Mar/2016:13:26:05 +0800] "GET /tomcat-demo/manager/http/ HTTP/1.1" 404 1019
10.215.22.132 - - [04/Mar/2016:13:40:33 +0800] "GET /manager/ HTTP/1.1" 302 -
10.215.22.132 - - [04/Mar/2016:13:40:33 +0800] "GET /manager/html?org.apache.catalina.filters.CSRF_NONCE=E68B5F7E6E96D09C75A8D6854ECE9092 HTTP/1.1" 401 2474
10.215.22.132 - yz [04/Mar/2016:13:40:35 +0800] "GET /manager/html?org.apache.catalina.filters.CSRF_NONCE=E68B5F7E6E96D09C75A8D6854ECE9092 HTTP/1.1" 200 12405
AJP를 사용하는 동안 처음 두 개의 로그 라인이 생성되었습니다. 마지막 3은 http를 사용하여 tomcat에 직접 액세스하는 동안 생성되었습니다. 따라서 아파치는 jkmount 접두사를 제거하는 대신 전체 URL을 Tomcat에 전달합니다.
답변
가능한 경우 mod_proxy_ajp 또는 mod_proxy_http를 대신 사용하십시오.
http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html
http://httpd.apache.org/docs/2.2/mod/mod_proxy_http.html