多站点configuration与Apache mod_proxy

我有一个大的服务器(临时的,有些网站会被转移到其他几个地方),我安装了我需要的所有工具(Jira,Bamboo等),现在我需要添加一个“常规”网站混合,而不是所有其他网站已经configuration不需要由Apache代理,并可以直接服务。

所以为了使它更清楚一点,我有Jira,竹和其他应用程序运行在他们的独立的Tomcat,为此Apache的代理请求,我想添加一个普通的网站到这个configuration,但是当我添加我的虚拟主机configuration所有网站出现故障

这是我的configuration文件:

apache2.conf:

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 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 denied </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 IncludeOptional conf-enabled/*.conf IncludeOptional sites-enabled/*.conf 

tomcat独立后的应用程序示例configuration文件(有4个这样的):

 <VirtualHost *> ServerName jira.example.com # Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts) ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://example.com:8080/ ProxyPassReverse / http://example.com:8080/ <Location /> Order allow,deny Allow from all </Location> LogLevel info ErrorLog ${APACHE_LOG_DIR}/jira_error.log CustomLog ${APACHE_LOG_DIR}/jira_access.log combined </VirtualHost> 

新vHost的configuration文件(正在进行中):

 <VirtualHost *:80> ServerAdmin [email protected] ServerName testing.example.com DocumentRoot /var/atlassian/application-data/bamboo/xml-data/build-dir/DFWA-DFWAAT2-DEV CustomLog /var/log/apache2/testing/access.log combined ErrorLog /var/log/apache2/testing/error.log ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://testing.exemple.com/ ProxyPassReverse / http://testing.exemple.com/ <Location /> Order allow,deny Allow from all require all granted </Location> </VirtualHost> 

我也有一个phpmyadmin的configuration文件,我不认为是需要解决我们的问题在这里。

我改变了几个新的虚拟主机文件,导致不同的行为:

我从一个小configuration文件(serveradmin,servername,documentroot和日志configuration)开始,但是当我添加文件没有网站可用了403 Forbidden错误,并没有在error.log或access.log

我试图添加一个像这样的目录指令:

 <Directory "/var/atlassian/application-data/bamboo/xml-data/build-dir/DFWA-DFWAAT2-DEV"> Options FollowSymLinks Require all granted </Directory> 

有了这个新的网站是可达的,但其他网站都重新导向到新的网站。

然后,我试着上面发布的文件,并与这一个请求陈旧,当我试图访问不同的网站,并在某些时候,他们返回一个代理错误,因为一个无效的响应(从远程服务器读取错误)。 我有这个在我的error.log:

 [mpm_prefork:error] [pid 20284] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting 

改变mpm_prefork的configuration虽然没有太大的作用。

我不知道接下来要做什么。 有什么build议么?

这个<VirtualHost *>不正确是不是一个错字? 也许<VirtualHost *:80>会更好?

这在标准的虚拟主机定义中看起来很奇怪

 ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://testing.exemple.com/ ProxyPassReverse / http://testing.exemple.com/ 

并且几乎可以肯定会导致请求工作人员用尽,因为您已经创build了一个循环,将tests.example.com反向代理与tesing.example.com进行反向代理。

从简单的事情开始,从中build立起来。

 <VirtualHost *:80> ServerAdmin [email protected] ServerName testing.example.com DocumentRoot /var/atlassian/application-data/bamboo/xml-data/build-dir/DFWA-DFWAAT2-DEV CustomLog /var/log/apache2/testing/access.log combined ErrorLog /var/log/apache2/testing/error.log </VirtualHost> 

我在这里回答发布现在正在工作的configuration。

我所要做的就是在代理网站上添加端口

 <VirtualHost *:80> 

并添加目录语句以允许访问/:

 <Directory /> require all granted </Directory> 

虚拟主机configuration文件:

 <VirtualHost *:80> ServerAdmin [email protected] ServerName example.com DocumentRoot /var/atlassian/application-data/bamboo/xml-data/build-dir/DFWA-DFWAAT2-DEV <Directory /> require all granted </Directory> CustomLog /var/log/apache2/testing/access.log combined ErrorLog /var/log/apache2/testing/error.log </VirtualHost> 

再次感谢@lain的帮助。