I have enabled keep-alive but it isn't working - linux

I have enabled the keep-alive option in my WHM
but I still get "close" when I have checked by many tools like this
http://www.giftofspeed.com/check-keep-alive/
http://gtmetrix.com/
And I have added the code in .htaccess file but the option is still not working
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
And when I create php file to print "HTTP_CONNECTION"
I get "close"
Thanks a lot

You have to reconfigure apache to have it handle keepalive.
The most relevant settings are:
KeepAlive On
Keepalivetimeout 5
MaxKeepaliveRequests 100
See the documentation here:
http://httpd.apache.org/docs/current/en/mod/core.html#keepalive
And a discussion which points to some caveats here:
https://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html

Related

Wordpress for Linux - Max-age never set

I have deployed a wordpress for linux app on an azure. It is working fine but I cannot get the Cache-Control header to set a max-age.
I am using the w3 total cache plugin and have set the options "Set expires header" with a value of 31536000 and "Set Cache Control policy" to Cache with max-age for css,js and media.
I can then see all the correct changes made in the htaccess file.
But the max-age value never gets set in the response Cache-Control header
I ran a phpinfo() and results are as follows
Apache Version Apache/2.4.25 (Unix) OpenSSL/1.0.2g PHP/7.1.2
Apache API Version 20120211
Server Administrator [no address given]
Hostname:Port 172.18.0.5:80
User/Group www-data(33)/33
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 60 - Keep-Alive: 5
Virtual Server Yes
Server Root /usr/local/httpd
Loaded Modules core mod_so http_core prefork mod_authn_file mod_authn_core mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_core mod_access_compat mod_auth_basic mod_reqtimeout mod_filter mod_mime mod_log_config mod_env mod_headers mod_setenvif mod_version mod_ssl mod_unixd mod_status mod_autoindex mod_dir mod_alias mod_rewrite mod_php7
In the loaded modules there is no mod_expires listed which would probably indicate this may be the problem.
BUT how do I install this..?

X-Frame-Options: .htaccess vs httpd.conf

In httpd.conf (Unix / Mac OS Sierra) I've got "Header set X-Frame-Options SAMEORIGIN"
I'd like to override that for a specific directory to
X-Frame-Options ALLOW-FROM SpecificDomain.com
Goal is to allow iframe acess to that directory but no others.
I tried adding the ALLOW-FROM line to an .htaccess file in the target directory but no luck. iFrame is denied, browser console saying "X-Frame-Options" are set to "SAMEORIGIN"
There are compatibility issues with some browsers with the Allow-From parameter for X-Frame-Options response header, chances are you are dealing with a browser which does not support it.
Ideally try this command to see the headers output and make sure the setting you made is being used:
curl -I http://yourserver.example.com/exceptionpath/
If it is, instead of setting that other header you may also want to unset that header in that directory to avoid compatibility issues with that parameter:
Header unset X-Frame-Options
or if the above is not being applied:
Header always unset X-Frame-Options
Sidenote: If you are the admin of the site you don't need to use .htaccess if you have access to main configuration files, set in the appropiate Directory entry instead. Disable .htaccess files altogether with AllowOverride none. Configurations will be simpler and you will gain a bit of performance by not forcing httpd to constantly read that file several times with each hit.

Magento keep alive response: connection close

I am trying to add a KeepAlive statement to my htaccess. I've set it like this:
<IfModule mod_headers.c> Header set Connection keep-alive </IfModule>
I i tested this, I got the response close on the connection!
Does someone know how to resolve this?
I am on magento 1.7.
For those who search for an answer:
KeepAlive have to be activated by your Hoster. Then you can enable it in your htaccess.

"Connection: Keep-Alive, close" as Response Headers

The question that I have might be pretty basic, but I can't find any solution. I'm trying to make keep-alive works, but it seem as if it was impossible as long as I get "Connection: keep-alive, close" as Response Headers.
I have the following code in my .htaccess, but it doesn't make any change:
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
What can I do?
You are getting both keep-alive and close because you need to edit this at the server conf level (ie: your vhost or httpd.conf)
If you simply do this through .htaccess it'll append the keep-alive to the close coming from your .conf. If you have access to the confs, try to update it to the following:
KeepAlive On
KeepAliveTimeout 15
MaxKeepAliveRequests 100

Apache , NodeJs, Server Sent Events

First of all, I know (Putting Node under Apache) this is not the approach to go but due to time constraint I cannot experiment.
I am trying to use Server Sent events for a mobile application. After reading all over Net, I figured out that Nodejs is the server to go for. My 80/443 port is occupied by Apache Web server, so I want Node To run behind Apache.
The Problems which I am facing are:-1. I am not able to get the close/end events on refreshing browser or closing browser rather I get after a fixed certain amount of delay, so not able to maintain when the client shuts down connection in Nodejs.
req.on("close", function() {
removeConnection(res);
console.log('Connection closed');
});
2. Apache is sending Keep-Alive:timeout=5, max=100 which I dont want as I want client to be connected forever till anyone closes connection, due to this Browser automatically closes connection and I start getting net::ERR_INCOMPLETE_CHUNKED_ENCODING. How Can I modify this value only for Node Proxy Requests.I have added ProxyPass /events http://localhost:5000/events
ProxyPassReverse /events http://localhost:5000/eventsResponse Headers
Access-Control-Allow-Headers:key,origin, x-requested-with, content- type,Accept,Content-Type
Access-Control-Allow-Methods:PUT, GET, POST, DELETE, OPTIONS
Access-Control-Allow-Origin:*
Connection:Keep-Alive
Content-Type:text/event-stream; charset=utf-8
custom:header
Date:Wed, 13 Jan 2016 18:12:48 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.7 (Ubuntu)
Transfer-Encoding:chunked
X-Powered-By:Express
Note:- All this is happening when I am using Apache to proxy to Node, else if I directly hit Node (which I cannot in prod due to blocked port) everything works fine.
The KeepAlive settings by default allowed only in server or virtual host configuration.
But during the request processing, apache2 use environment variables (based on apache configuration) to determine the current settings.
Fortunately with mod_rewrite, you can alter apache environment variables on request basis, so you can disable keepalive on specific request.
For example:
#Load rewrite module
LoadModule rewrite_module modules/mod_rewrite.so
#Enable mod_rewrite functionality
RewriteEngine On
#rewrite rule inside locationmatch
<LocationMatch ".*\/sse\/.*">
#This is not required, used only for debug purposes
Header set X-Intelligence "KEEPALIVEOFF"
#Here goes the mod rewrite environment variable trick
RewriteRule .* - [E=nokeepalive:1]
</LocationMatch>

Resources