ProxyPass工作者主机名太长,在apache2(2.4.7 Ubuntu 14.04 LTS),如何解决这个问题?

我必须将apache2设置为来自内部AWS ELB的反向代理。 ELB的URL是85个字符。 使用虚拟主机进行设置会失败,因为它会产生错误

ProxyPass worker hostname (internal-elb-greater-than-64-character-url-that-fails-in-apache-aws.amazon.com) too long. 

如果ELBurlless于或等于64个字符,这个效果会很好。

configuration文件看起来像/etc/apache/sites-enabled/000-sites.conf (实际的ELB和网站的名称被replace)

 <VirtualHost *:80> ProxyPreserveHost On ServerName www.mydomain.com ServerAdmin me@mydomain.com DocumentRoot /var/www/html RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker.* RewriteRule . https://www.mydomain.com%{REQUEST_URI} [R=301,L] ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ProxyPass /test/ http://localhost:8080/ ProxyPassReverse /test/ http://localhost:8080/ ProxyPass / http://internal-elb-greater-than-64-character-url-that-fails-in-apache-aws.amazon.com/ ProxyPassReverse / http://internal-elb-greater-than-64-character-url-that-fails-in-apache-aws.amazon.com/ </VirtualHost> 

我已经能够使用nginx/etc/nginx/nginx.conf

 server { listen 80; server_name localhost; root /usr/share/nginx/html; #access_log /var/log/nginx/host.access.log main; location /test/ { if ( $http_x_forwarded_proto != 'https' ){ rewrite ^ https://www.mydomain.com$request_uri? permanent; } proxy_pass http://localhost:8080/; } location / { if ( $http_x_forwarded_proto != 'https' ){ rewrite ^ https://www.mydomain.com$request_uri? permanent; } proxy_pass http://internal-elb-greater-than-64-character-url-that-fails-in-apache-aws.amazon.com/; } location /elb-status { return 200; } # redirect server error pages to the static page /40x.html # error_page 404 /404.html; location = /40x.html { } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { } } 

Nginx可以根据需要工作 – 修改PING URL进行运行状况检查。

我想知道什么可以在apache2(2.4.7 Ubuntu 14.0 LTS)的等效configuration。 我在Fedora的apache2.4.9上试过,结果还是一样的。

我怎么能得到apache2的工作,因为我们不考虑内部负载均衡之前的nginx – 这不是我的决定。

你需要使用mod_rewrite:

https://issues.apache.org/bugzilla/show_bug.cgi?id=53218

关于重写: http : //httpd.apache.org/docs/2.4/rewrite/

所以我的猜测(未测试):

 RewriteRule ^/(.*)$ http://internal-elb-greater-than-64-character-url-that-fails-in-apache-aws.amazon.com/$1 [P]