LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 12-22-2013, 06:44 AM   #1
jhon123
LQ Newbie
 
Registered: Dec 2013
Posts: 9

Rep: Reputation: Disabled
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?

Thanks a lot
 
Old 12-22-2013, 11:14 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,262

Rep: Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440
Quote:
Originally Posted by jhon123 View Post
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.
 
Old 12-23-2013, 08:38 AM   #3
jhon123
LQ Newbie
 
Registered: Dec 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
Old 12-23-2013, 08:45 AM   #4
jhon123
LQ Newbie
 
Registered: Dec 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
Old 12-23-2013, 11:26 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,262

Rep: Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440
Quote:
Originally Posted by jhon123 View Post
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.

And your question is still a bit unclear, but there is ample documentation/explanations about how to use external scripts and programs with mod_security:
http://www.modsecurity.org/documenta...-examples.html
http://www.linuxforu.com/2011/08/sec...-mod_security/

You still don't say what your web pages are written in, and why you can't put the 'delay' in the pages themselves.
 
Old 12-24-2013, 02:02 AM   #6
jhon123
LQ Newbie
 
Registered: Dec 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
Unhappy 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?
 
Old 12-24-2013, 10:57 AM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,262

Rep: Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440
Quote:
Originally Posted by jhon123 View Post
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???
 
Old 12-27-2013, 03:26 PM   #8
jhon123
LQ Newbie
 
Registered: Dec 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
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?

It would be your kind if you help me.
Thanks alot
 
Old 12-27-2013, 03:40 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,262

Rep: Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440
Quote:
Originally Posted by jhon123 View Post
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.
 
Old 01-01-2014, 02:43 AM   #10
jhon123
LQ Newbie
 
Registered: Dec 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
Old 01-01-2014, 11:30 AM   #11
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,262

Rep: Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440Reputation: 4440
Quote:
Originally Posted by jhon123 View Post
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?
The script tells you it can use it...you don't say where you got this script, but did you read the instructions for it??? And again, did you try to read the documentation?
http://perl.apache.org/docs/2.0/user/handlers/http.html
http://www.apacheref.com/ref/mod_per...itHandler.html
Quote:
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache response "HTTP request sent; waiting for response" too long ALInux Linux - Server 1 07-19-2011 07:45 PM
HTTP request sent, awaiting response... 401 Unauthorized Franxie Linux - Networking 1 06-17-2009 02:37 AM
HTTP REQUEST to Apache server from C program Balakrishnan84 Programming 6 07-26-2007 05:00 AM
host unreachable when making http request hradtke Linux - Networking 2 05-27-2007 11:25 AM
Request for http.conf file for Apache 1.3.26 Thinkgeekness Linux - Software 2 04-19-2003 01:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration