Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Problem using mod_deflate with proxy |
|
Author |
|
john_speedway2
Joined: 23 Dec 2005 Posts: 8
|
Posted: Wed 02 Jan '08 21:31 Post subject: Problem using mod_deflate with proxy |
|
|
Is anyone succesfully able to compress HTML pages while using mod_proxy_ajp to forward requests to Tomcat 6?
I've tried using several configurations but the web page is always returned uncompressed.
Here's my current Apache 2.2.6 config ...
<VirtualHost *:8080>
DocumentRoot /www/docs/mywebsite.com
ServerName www.mywebsite.com
<Proxy balancer://mywebsite_cluster>
BalancerMember ajp://www.mywebsite.com:8009 min=10 max=100 route=node01 loadfactor=1
</Proxy>
<Location / >
ProxyPass balancer://mywebsite_cluster/ stickysession=JSESSIONID lbmethod=byrequests nofailover=off
ProxyPassReverse balancer://mywebsite_cluster/
SetOutputFilter DEFLATE
</Location>
</VirtualHost>
Any suggestions?
Thanks,
John |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Thu 03 Jan '08 5:10 Post subject: |
|
|
I had no trouble getting compressed pages with your setup using Apache 2.2.6 on Windows with Tomcat 6.0.14.
A couple of things (which you may already know):* Comment out the <Connector> for port 8080 in Tomcat's server.xml if Tomcat runs on the same machine as Apache.
* Enable listening to port 8080 in Apache with Listen 8080, so the request goes through Apache and not directly to Tomcat.
Put this Listen directive outside the <VirtualHost> block.
* Make sure the request you are testing with is HTTP 1.1 and has an Accept-Encoding header which allows gzip compression Here's a request and its 113-byte response which shows compression (using netcat to port 8080): Code: | GET /test.jsp HTTP/1.1
Host: localhost
Accept-Encoding: gzip,deflate
HTTP/1.1 200 OK
Date: Thu, 03 Jan 2008 03:00:02 GMT
Set-Cookie: JSESSIONID=221D1FDBAD5AB80C49DE3BAC35CD7971; Path=/
Content-Type: text/html
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 113
▼ ♥│╔(╔═▒│I╩O⌐┤πσR ☻¢♀C╗Æ╘Γ↕╜¼Γ☻←} çù+<5E┴+1O┴└H┴╚╚╩└└╩└T┴58D┴╚└└éù╦&¿♠ñEüt
bT3²5█Φâú←↑╣á╕Wá▲ασ☻ Dâ☺╟O☻ |
and here's the same request and its 591-byte response without mod_deflate : Code: | GET /test.jsp HTTP/1.1
Host: localhost
Accept-Encoding: gzip,deflate
HTTP/1.1 200 OK
Date: Thu, 03 Jan 2008 03:00:30 GMT
Set-Cookie: JSESSIONID=03A4A3E5883F2C119FC97F447E3BD581; Path=/
Content-Type: text/html
Content-Length: 591
<html><body>
<h1>test.jsp</h1>
Wed Jan 02 22:00:33 EST 2008
<br>
test test test test test test test test test test test <br>
test test test test test test test test test test test <br>
test test test test test test test test test test test <br>
test test test test test test test test test test test <br>
test test test test test test test test test test test <br>
test test test test test test test test test test test <br>
test test test test test test test test test test test <br>
</body></html> |
I'm not sure what could be different in your setup. I doubt it is platform-specific, although I tried it on Windows and you apparently are using Unix.
-tom- |
|
Back to top |
|
john_speedway2
Joined: 23 Dec 2005 Posts: 8
|
Posted: Thu 03 Jan '08 9:23 Post subject: |
|
|
Thank you Tom! I've modifed the config file and it works!!
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot /www/docs/mywebsite
ServerName local.mywebsite.com
<Proxy balancer://mywebsite_cluster>
BalancerMember ajp://local.mywebsite.com:8009 min=10 max=100 route=node01 loadfactor=1
</Proxy>
ProxyPass / balancer://mywebsite_cluster/ stickysession=JSESSIONID lbmethod=byrequests nofailover=off
ProxyPassReverse / balancer://mywebsite_cluster/
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
</VirtualHost>
Here are the HTTP headers as viewed with Firefox-LiveHttpHeaders.
GET / HTTP/1.1
Host: local.mywebsite.com:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.x 200 OK
Date: Thu, 03 Jan 2008 07:15:01 GMT
Cache-Control: no-cache
Pragma: no-cache
Path=/
Content-Type: text/html;charset=UTF-8
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Thanks so much for your help!
-John |
|
Back to top |
|
|
|
|
|
|