Monthly Archives: March 2012

Limit requests per IP on Nginx using HttpLimitZoneModule and HttpLimitReqModule except whitelist

- Make sure to check Nginx, PHP posts for information on Nginx and PHP setup and configuration.

Nginx offers two modules, HttpLimitReqModule and HttpLimitZoneModule, to limit simultaneous connections for the assigned session and the number of requests for a given session from one IP address. Basically these modules are built to protect the web server from possible DDos attacks; For example, this configuration limits remote clients to no more than 20 concurrently “open” connections per remote ip address:

http{
    limit_zone limit_per_ip $binary_remote_addr 5m;
    limit_conn  limit_per_ip  20;

Continue reading

Disqus problem with wordpress “unable to connect to the disqus api servers”

I recently installed Disqus plugin for WordPress; however, I have been receiving this message “unable to connect to the disqus api servers.” By looking into the source code, it looks like curl is the problem! more specifically the _dsq_curl_urlopen() function, but I did not investigate this error further. As fortunately, we can easily switch to the alternative function _dsq_fsockopen_urlopen().
Continue reading

Watch log files on Linux server with Swatch 3.2.3

- Make sure to check CentOS, PHP-FPM, memcached and MYSQL posts.

- get a fresh package from Swatch project

wget "http://downloads.sourceforge.net/project/swatch/swatch/3.2.3/swatch-3.2.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fswatch%2F&ts=1330806322&use_mirror=garr"
tar xfz swatch-3.2.3.tar.gz 
cd swatch-3.2.3
cpan -i Date::Format File::Tail
cpan -i Date::Manip Date::Calc
cpan -i Test::Inter Test::Pod Test::Pod::Coverage Module::Build
cp /root/.cpan/sources/authors/id/S/SB/SBECK/Date-Manip-* .
tar xfz Date-Manip-*.tar.gz
cd Date-Manip-*
perl Build.PL 
./Build install
cd ..
perl Makefile.PL
make install

- configure swatch
Continue reading

Install Nginx 1.0.12 for PHP-FPM on CentOS 6.2

- Make sure to check PHP-FPM, memcached and MYSQL posts.
- get the latest package from wiki.nginx.org

mkdir nginx
cd nginx
wget http://nginx.org/download/nginx-1.0.12.tar.gz
tar xfz nginx-1.0.12.tar.gz 
cd nginx-1.0.12
 
#Change server string
vi src/http/ngx_http_header_filter_module.c
#change
static char ngx_http_server_string[] = "Server: example.com" CRLF;
static char ngx_http_server_full_string[] = "Server: example.com" CRLF;
 
#change
vi src/http/ngx_http_special_response.c
# replace '"<hr /><center>nginx</center>" CRLF' and '"<hr /><center>" NGINX_VER "</center>" CRLF'
"<hr /><center>example.com</center>" CRLF
 
#create tmp dirs
mkdir /server/tmp /server/tmp/nginx /server/tmp/nginx/client /server/tmp/nginx/fcgi /server/tmp/nginx/proxy
chmod -R 777 /server/tmp

-install Nginx
Continue reading