我正在使用Apache 2.2.12和Tomcat 7.0.61。
我已经从这篇文章中省略了几个配置文件,因为除了一个上下文根之外的所有文件都在工作。
我在apache2的vhost目录中的vhost.conf文件中有几个jkmounts。除了一个,所有这些都有效。我在测试环境中有相同的配置文件,没有问题。相同的语法和一切。已对文件进行差异检查并检查行结束错误。我们正在运行由Novell打包的sles 11盒。服务上下文返回Forbidden。
错误日志:
- [Wed Mar 22 06:09:54 2017] [error] [client requestingip] client denied by server configuration: /srv/www/htdocs/services
- [Wed Mar 22 06:09:54 2017] [error] [client requestingip] client denied by server configuration: /srv/www/htdocs/favicon.ico, referer: https://sub.domain.com/services/request-path/
我完全失去了为什么当同一个webapps文件夹中托管的同一文件中同一工作人员的其他任何服务都没有这个时,这个上下文/srv/ww/htdocs/
优先。
重要的是要注意,如果我直接在Tomcat上调用这样的服务:
sub.domain.com:8080/services/path-to-function/##
。
它有效,但我们不应该直接命中Tomcat。下面是装载等 - 由于显而易见的原因,一些细节被欺骗。其他注意事项:
<VirtualHost _default_:80>
ServerName sub.domain.com:80
ServerAdmin admin@domain.com
ErrorLog /var/log/apache2/error_log
TransferLog /var/log/apache2/access_log
SSLEngine off
Alias /services "/opt/apache-tomcat-<version-num>/webapps/services"
<Directory "/opt/apache-tomcat-<version-num>/webapps/services">
</Directory>
JkMount /services/* worker1
<Location "/services">
Options Indexes FollowSymLinks Includes ExecCGI Multiviews
Order allow,deny
Allow from all
AuthType Basic
AuthName "Services"
AuthzLDAPAuthoritative on
AuthBasicProvider ldap
AuthLDAPURL ldaps://directory.domain.com/o=organization-tree?uid
Require ldap-group cn=service-users,o=oragnization-tree
AuthLDAPBindDN cn=user,o=organization-tree
AuthLDAPBindPassword p@ssWord
</Location>
<Location "/services/WEB-INF/">
Deny from all
</Location>
</VirtualHost>
我已就此问题审核了多个主题,文档和网站。
答案 0 :(得分:0)
在通过多个配置选项进行测试时,我意识到每个vHost配置都应该有一个IP地址或一个由端口继续的域。引导我实现这一目标的警告是apache的警告,即端口80的使用存在重叠,第一个将优先。通过为每个VirtualHost添加一个唯一的名称,将每个域分配给一个单独的IP并重新启动apache,我就能够消除这个问题。
示例:
<VirtualHost hostname-service.domain-1.com:80>
ServerName sub.domain-1.com:80
ServerAdmin admin@domain.com
ErrorLog /var/log/apache2/error_log
TransferLog /var/log/apache2/access_log
SSLEngine off
Alias /services "/opt/apache-tomcat-<version-num>/webapps/services"
<Directory "/opt/apache-tomcat-<version-num>/webapps/services">
</Directory>
JkMount /services/* worker1
<Location "/services">
Options Indexes FollowSymLinks Includes ExecCGI Multiviews
Order allow,deny
Allow from all
AuthType Basic
AuthName "Services"
AuthzLDAPAuthoritative on
AuthBasicProvider ldap
AuthLDAPURL ldaps://directory.domain.com/o=organization-tree?uid
Require ldap-group cn=service-users,o=oragnization-tree
AuthLDAPBindDN cn=user,o=organization-tree
AuthLDAPBindPassword p@ssWord
</Location>
<Location "/services/WEB-INF/">
Deny from all
</Location></VirtualHost>
<VirtualHost hostname-service.domain-2.com:80>
ServerName sub.domain-2.com:80
ServerAdmin admin@domain.com
ErrorLog /var/log/apache2/error_log
TransferLog /var/log/apache2/access_log
SSLEngine off
Alias /services "/opt/apache-tomcat-<version-num>/webapps/services"
<Directory "/opt/apache-tomcat-<version-num>/webapps/services">
</Directory>
JkMount /services/* worker1
<Location "/services">
Options Indexes FollowSymLinks Includes ExecCGI Multiviews
Order allow,deny
Allow from all
AuthType Basic
AuthName "Services"
AuthzLDAPAuthoritative on
AuthBasicProvider ldap
AuthLDAPURL ldaps://directory.domain.com/o=organization-tree?uid
Require ldap-group cn=service-users,o=oragnization-tree
AuthLDAPBindDN cn=user,o=organization-tree
AuthLDAPBindPassword p@ssWord
</Location>
<Location "/services/WEB-INF/">
Deny from all
</Location></VirtualHost>