Board index Linux Apache

Moderator: chandranjoy

Apache - Tweaks

Postby chandranjoy » Sun Mar 07, 2010 6:37 pm

1.apachectl:

start : Start the Apache httpd daemon. Gives an error if it is already running.

stop : Stops the Apache httpd daemon.

graceful : Gracefully restarts the Apache httpd daemon. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted.

restart : Restarts the Apache httpd daemon. If the daemon is not running, it is started. This command automatically checks the configuration files as in configtest before initiating the restart to make sure the daemon doesn't die.

status
: Displays a brief status report.

fullstatus
: Displays a full status report from mod_status. Requires mod_status enabled on your server and a text-based browser such as lynx available on your system. The URL used to access the status report can be set by editing the STATUSURL variable in the script.

configtest:

-t Run a configuration file syntax test.
__________________________________________________________________________________________________

2.How to Limit IP downloads in Apache using with 'LimitIPConn'
Apache module mod_limitipconn.c, which allows web server administrators to limit the number of simultaneous downloads permitted from a single IP address.

Installing mod_limitipconn.c:

Installing this was quick and easy. Login to your server through shell as the root user.
# wget tar xzvf mod_limitipconn-0.04.tar.gz
# cd mod_limitipconn-0.04
# vi Makefile

Find
APXS = apxs

CHANGE TO:
APXS = /usr/local/apache/bin/apxs

Save
#make
#make install


This adds the module to httpd.conf and backs up the old configuration from httpd.conf.new

# vi /usr/local/apache/conf/httpd.conf

It should have added the following:
LoadModule limitipconn_module libexec/mod_limitipconn.so

and
AddModule mod_limitipconn.c


Now we need to setup the configuration for the site you want to add the limits to. Search the domain you want and go to the configuration for it in httpd.conf

You should be at the part like this:

<VirtualHost IP HERE>
ServerAlias http://www.domain.com domain.com


Add the following configuration that you want, this restricts 2 directories I have on my site to prevent users from downloading more than 1 video at a time, I have 2 separate rules.

<IfModule mod_limitipconn.c>
<Location /videos>
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video
</Location>

<Location /forums/media/data>
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video
</Location>

</IfModule>



So my whole entry for the domain looks like this:

<VirtualHost IPHERE>
ServerAlias http://www.domain.com domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /home/domain/public_html
BytesLog domlogs/domain.com-bytes_log
ServerName http://www.domain.com
<IfModule mod_php4.c>
php_admin_value open_basedir "/home/domain:/usr/lib/php:/usr/local/lib/php:/tmp"
</IfModule>
<IfModule mod_limitipconn.c>
<Location /videos>
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video
</Location>

<Location /forums/media/data>
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video
</Location>

</IfModule>
User domain
Group domain
CustomLog domlogs/domain.com combined
ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/
</VirtualHost>


Save httpd.conf

Test Apache Configuration
# apachectl configtest start

Make sure it comes back ok without errors
# /scripts/restartsrv_httpd
(In Cpanel servers)


3.How to hide the port number in URL under Linux Webserver?


At the bottom of your domain's VirtualHost directive, add the following lines:
ProxyRequests Off
ProxyPass / http://domain.com:12013/
ProxyPassReverse / http://domain.com:12013/

Finally, restart Apache:
service httpd restart

Please note this will work with Apache 2.x (mod_proxy is inbuilt)
chandranjoy
Site Admin
 
Posts: 283
Joined: Fri Oct 23, 2009 11:19 pm

Return to Apache

Who is online

Users browsing this forum: No registered users and 1 guest


cron