AJP连接器无法正常工作? (404错误)

时间:2015-07-08 10:19:16

标签: apache tomcat tomcat7 mod-jk ajp

我正在尝试将Apache WebServer(2.4.10)连接到Tomcat 7,它们都位于两个不同的VM中。这是我第一次使用这些工具。根据我的理解,检查连接是否正常的方法是尝试使用URL IP/instance访问Tomcat,而不是,如果我在8080端口上有Tomcat IP:8080/instance。但是,每次我尝试这样做时,Apache都会返回404错误。这是我的配置:

在Tomcat的VM上,server.xml包含以下行:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443 />

在Apache的VM上,我设置了这些文件:

apache2.conf(在Apache主文件夹中)

Servername apache
Include httpd.conf
ServerRoot "/etc/apache2"

Mutex file:${APACHE_LOCK_DIR} default

PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Include ports.conf

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

httpd.conf(在Apache主文件夹中,conf-available和conf-enabled中的符号链接)

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

workers.properties(在/ etc / libapache2-mod-jk中)

workers.tomcat_home=/usr/share/tomcat7

workers.java_home=/usr/lib/jvm/java-7-openjdk-amd64

ps=/

worker.list=agent1
worker.maintain=3600

worker.agent1.port=8009
worker.agent1.host=192.168.2.97
worker.agent1.type=ajp13

worker.agent1.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=agent1

jk.conf(在mods-available文件夹中,在启用mods的链接中)

JkWorkersFile /etc/libapache2-mod-jk/workers.properties

JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkShmFile /var/log/apache2/jk-runtime-status

JkWatchdogInterval 60

JkMount     /gameoflife/*   agent1 
JkMount     /gameoflife     agent1
JkMount     /gameoflife*    agent1

<Location /jk-status>
    JkMount jk-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>
<Location /jk-manager>
    JkMount jk-manager
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>

我知道这可能是一团糟,因为我尝试了不同的指南并尽一切努力让它工作但我仍然得到404错误。我怎么能让它工作?提前谢谢。

1 个答案:

答案 0 :(得分:0)

出于某些原因,一旦我尝试(在绝望中)实现负载平衡器,即使没有AJP连接器在单个服务器上工作,它也开始工作,因为这是从最初的目标开始。超快乐。

最后,我还在启用了网站的JkMount文件中编写了000-default.conf条指令,正好在VirtualHost< *:80> istruction中。也许这是为了正常工作所必需的。