Gzip in apache-tomcat - .htaccess

I want to enable gzip for compression and I have tried many blocks of code. Unfortunately, nothing works. The server that my host is using is apache-tomcat. Do they use different code for enabling gzip or deflate? I only have access to .htaccess. Can someone please post the proper code for enabling gzip (or deflate) on apache-tomcat?

There is no .htaccess in Tomcat. This file belongs to the Apache Web Server. GZIP compression can be enabled in the HTTP connector. Your question is for serverfault and not stackoverflow.

Related

IIS 8.5 Static Compression missing Content-Encoding response header, yet Failed Request Tracing shows compression with gzip

I observed that Content-Encoded response header was missing, notably Content-Encoded: gzip. I'm using static content compression. The dynamic content compression feature was never installed. I installed it, enabled it, and tested again. This time, Content-Encoded: gzip appeared in the response. The question is why does the response header appear for dynamic content compression but not for static content compression? I'm fairly certain that IIS is applying gzip to static content compression. Here's why:
I have an IIS URL Rewrite outbound rule which modifies the response on an HTML page. The outbound rule yielded Error 500.52, URL Rewrite Module error -- Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip"). The rule is not the issue, just evidence that gzip is reportedly being applied. I disabled the rule. That's clue #1.
Clue #2 is I enabled Failed Request Tracing and observed that not only static compression was being applied but the StaticFileModule was storing the compressed file in the following location: C:\INETPUB\TEMP\IIS TEMPORARY COMPRESSED FILES\MY WEBSITE\$^_GZIP_D^\INETPUB\WWWROOT\TEST.HTML.
I read the Microsoft document on IIS HTTP Compression and--I could be wrong--I didn't see any language that suggests gzip can be employed with static compression. Based on the two clues above, gzip is being employed with static compression.
So I go back to the original problem, which is Content-Encoded response header is missing for static content impression, yet evidence suggests that IIS is not only compressing static content but compressing it with gzip. Is this simply a bug? Is this by design?
Static Compression will add Content-Encoded header when it work.
If you enable failed request tracing and trace static compression module. You will see this.
It means static compression won't work if a static file didn't get hit frequently.
If you relay this request doezens times. Then you will see that header.
Be careful that, there is a limit for minimum file size for compression. You could modify that value in IIS manager->server node->configuration manager->system.webServer/httpCompression->minfileforcomp

What happens if a browser doesn't support gzip?

I'm using mod_deflate to enable gzip on a site via the .htaccess file.
What happens if a browser that doesn't support gzip visits the site ?
Then the server doesn't send gzip. That's the whole point of the "Accept-Encoding:" heading from the browser, which indicates this by not having "gzip" in that header.

set http only and secure flag for cookies in lighttpd

We are using lighttpd web server in our code base. It is that we need to add SECURE and HTTP ONLY flags for the cookie.
I have gone through many examples but all are related to PHP and some other kanguage. We don't use PHP in our code. Is there anyway that I can get this? Can anything be done in the .conf file like in apache web server.
I have tested apache web server by adding changes in the httpd.conf and checked the packet capture. It worked. But unable to achieve this in lighttpd.
We use C language in the backend.
Well, To answer my own question.
There is nothing to do with the lighttpd.conf as of httpd.conf for apache.
We are setting the cookie header in a lua file(Kepler). Appending secure to that cookie header fixed the issue.

How to get mod_pagespeed working with SSL

I've got mod_pagespeed installed under apache2/php5-fpm and it's working fine on my domain that isn't using SSL (it's combining css and js no probs), however when I access the SSL version of the same site, it no longer works. I've tried setting the variable:
ModPagespeedFetchHttps enable
But it still is not working. The site is behind basic auth security, would this matter?
I can see in the response headers under the SSL version of the site that mod_pagespeed is there, but it's not working it's magic.
Does accessing resources require authentication? If so, then mod_pagespeed probably is not able to access them (it just does an http fetch for resources to rewrite).
Are the same resources available on http? If so, you're best bet might be MapOriginDomain:
ModPagespeedMapOriginDomain http://www.example.com/ https://www.example.com/
This will fetch all resources with HTTP even when the page is requested with HTTPS. So this would avoid the authentication issue.
See also, https://developers.google.com/speed/pagespeed/module/https_support for more help with various HTTPS issues.
In addition to the above answer, also make sure you have added the directory for the ModPagespeedSslCertFile in your config file.
Check "Configuring SSL Certificates" at
https://developers.google.com/speed/pagespeed/module/https_support

Is there any way to configure .htaccess to write to access.log file which is already handled by apache2.config

We have hosted our website with external agency, in the Linux environment.
now we have added cookies in our website code and want to track cookie in access.log. when we requested with our domain host provider they turn down the request to modify apache2.config file, instead they suggested to use .htaccess file to enable cookie in access.log. Right now we do not want to use any other method to log cookie other than .htaccess file.
we did not find any solutions to enable cookie in access.log using .htaccess file.
we need following questions to be answered.
1) Is it possible to use .htaccess file to enable cookie in access.log
2) If yes, steps to make it and it will be greatly appreciated if it is explained keeping it in mind that user is a layman.
As far as I know you cannot customize log files from .htaccess. And I think there is a valid reason of disabling this as it may impose security issues in a shared environment.
You would need to have the host enable mod_usertrack. Then they would need to allow you to override the configuration settings with .htaccess.
LogFormat "%{Apache}n %r %t" usertrack
CustomLog logs/clickstream.log usertrack
I track cookies, users, sessions, browsers, everything in a MySQL database. It's a lot easier to access the data with stats than log mining. (It does take up a bit of room though.)

Resources