Making delay for apache server to response to http request
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Making delay for apache server to response to http request
Hi dear users,
how can i make a delay when apache server wants to response to a request? i have a method of request processing and i want apache to not to response to request when i am processing that. how would it be possible to make a delay in httpd server response?
Hi dear users,
how can i make a delay when apache server wants to response to a request? i have a method of request processing and i want apache to not to response to request when i am processing that. how would it be possible to make a delay in httpd server response?
Thanks a lot
No idea, since you don't provide ANY details. Things like version/distro of Linux, version of Apache, what your 'method' is, how it's written, what it does, what your goal is, etc.
First response would be to put the delay in your 'method'...that way, if things change in the future and you don't need it, you don't have to tinker with Apache to speed it up again. And add to that the fact that any delays would be on ALL the pages Apache serves (even those you WANT to be faster), and it seems to be a bad idea. But again, without details, there's little we can tell you.
Making delay for apache server to response to http request
hi dear,
my Linux is Centos 6.4, my apache server is httpd 2.3.2 version and I have installed modsecurity as a firewall on my apache server. Each time Modsecurity makes a log of bad requests and I want to analyze this log file for each request. I want to make a delay for server response when I am processing and analyzing the bad request log. How can I do this task?
thanks a lot for your kind
Making delay for apache server to response to http request
hi dear,
my Linux is Centos 6.4, my apache server is httpd 2.3.2 version and I have installed modsecurity as a firewall on my apache server. Each time Modsecurity makes a log of bad requests and I want to analyze this log file for each request. I want to make a delay for server response when I am processing and analyzing the bad request log. How can I do this task?
thanks a lot for your kind
hi dear,
my Linux is Centos 6.4, my apache server is httpd 2.3.2 version and I have installed modsecurity as a firewall on my apache server. Each time Modsecurity makes a log of bad requests and I want to analyze this log file for each request. I want to make a delay for server response when I am processing and analyzing the bad request log. How can I do this task?
thanks a lot for your kind
Posting the same reply twice doesn't get an answer any faster.
Making delay for apache server to response to http request
Hi dear Tb0ne,
My web pages are written in php. how would it be to make a delay in pages? Also if I prefer to make a delay in web server itself, how would it be?
There is no way to use modsecurity for doing that. Is there any way by sleep function or something else? how would it be?
Hi dear Tb0ne,
My web pages are written in php. how would it be to make a delay in pages?
If you wrote the PHP pages, then check your PHP programming guides for use of the 'sleep' function. You could also just put a loop somewhere that waits until it gets a response, or do one of a thousand different things. That's up to you...and since you have the page source, it's also easy.
Quote:
Also if I prefer to make a delay in web server itself, how would it be? There is no way to use modsecurity for doing that. Is there any way by sleep function or something else? how would it be?
Yes, there IS a way...again, I gave you a link to mod_security, and it's ability to use an external script. Back to 'sleep' in a bash script, right???
Making delay for apache server to response to http request
Quote:
Yes, there IS a way...again, I gave you a link to mod_security, and it's ability to use an external script. Back to 'sleep' in a bash script, right???
Hi again dear user,
I can not find exactly how would it be by modsecurity?how modsecurity can use sleep in a bash script? Are there more details about doing that?
Hi again dear user,
I can not find exactly how would it be by modsecurity?how modsecurity can use sleep in a bash script? Are there more details about doing that?
It would be your kind if you help me.Thanks alot
Yes, there are details...if you READ THE LINK YOU WERE PROVIDED. It TELLS YOU how to use an external script/program, and has SAMPLES on how to do it. Not sure how much more plain it needs to be.
Making delay for apache server to response to http request
hi dear TB0ne,
Thank you for your previous post and links. I just know how to use an external script by modsecurity but there are some problems with me. First of all is that i am not good at perl. i try to write a code by perl but i was not successful to do something that i want. Finally i searched alot and i found a code in perl for doing this task but i could not use it and i do not know if it is useful or not. here is that code:
Quote:
package MyDelay;
# This package can be used in conjunction with a
# PerlInitHandler directive to slow down a connection
# based on an ip address
# Example: set in perl.conf
# To slow down a particular request
#<Location /delay_test.html>
# PerlInitHandler MyDelay
#</Location>
#
# or outside of any Location, File, etc to slow down all requests
# PerlInitHandler MyDelay
use strict;
use Apache2::RequestRec;
use Apache2::Const; # for OK
use Apache2::Connection; # for remote_ip
sub handler
{
my $r = shift;
my($c);
my($ip_addr);
$c = $r->connection;
$ip_addr = $c->remote_ip;
if ($ip_addr eq "my ip address")
{
print STDERR ("in MyDelay:handler\n");
print STDERR ("ip_addr = $ip_addr\n");
sleep (30);
}
return OK;
}
1;
do you think that this code is useful or not? how can i use it? does it need PerlinintHandler or something like this?
Another thing is that i am now trying to use iptables for making delay in apache response. For example blocking port 80 for 5 seconds. would it be useful?
I really need your help.
I thank you in advance
hi dear TB0ne,
Thank you for your previous post and links. I just know how to use an external script by modsecurity but there are some problems with me. First of all is that i am not good at perl. i try to write a code by perl but i was not successful to do something that i want. Finally i searched alot and i found a code in perl for doing this task but i could not use it and i do not know if it is useful or not. here is that code:
do you think that this code is useful or not?
If that code does what you want it to do, then it's OBVIOUSLY useful. If it doesn't, then it's not.
Quote:
how can i use it?
AGAIN, you read the instructions you were GIVEN before.
Quote:
does it need PerlinintHandler or something like this?
Another thing is that i am now trying to use iptables for making delay in apache response. For example blocking port 80 for 5 seconds. would it be useful?
Please go back and re-read what has been told to you from the very beginning. You are wanting to put a delay in certain web pages...you have gone from Apache mod_security, to an external script, and now to iptables. PICK ONE.
AGAIN, as has been told to you before, the best way to do this is to PUT THE SLEEP FUNCTION INTO THE WEB PAGE CODE ITSELF, for only the pages you want to have a delay. That's it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.