Friday, February 26, 2010

Anti-DDOS NGINX Server Configuration includes PHP config

Here is my NGINX configuration for DDOS Attacks to PHP and my lovely NGINX server:
nginx.conf
user www-data www-data;
worker_processes 10;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

access_log /var/log/nginx/access.log;

sendfile on;

#keepalive_timeout 0;
keepalive_timeout 5;
tcp_nodelay on;

gzip on;
limit_req_zone $binary_remote_addr zone=antiddosphp:10m rate=1r/s;
limit_req_zone $binary_remote_addr zone=antiddos:10m rate=10r/s;

include /etc/nginx/mustafat/*;

}
virtualhost.conf
server {
root /home/www-data/vpswatch.com;
listen 80;
server_name vpswatch.com;

access_log off;

location / {
index index.php index.html index.htm;
limit_req zone=antiddos burst=10;

}
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 1800;
fastcgi_param SERVER_NAME $http_host;
fastcgi_ignore_client_abort on;
limit_req zone=antiddosphp burst=2;
}
}

Monday, February 1, 2010

Findout Linux Distrubution Name of your Linux

lsb_release -a

Change the timezone, date time on linux

ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
In this command important part is giving the path of your timezone(bold one in example).

Monday, January 18, 2010

Change Default Editor on Linux

#set | grep EDITOR
EDITOR=/bin/pico
# which vi
/usr/bin/vi
# export EDITOR=/usr/bin/vi
# set | grep EDITOR
EDITOR=/usr/bin/vi
_=EDITOR

Wednesday, October 21, 2009

Deleting Files Based on Date Time

Today I needed to delete files based on date and time:
Here is the command I used for deleting file last modified on 21 Oct 2009 16:30:
ls -lh | sed -n '/Oct\ 21\ 16:30/p' | awk '{print $9}' >> 1.txt
rm -f `cat 1.txt`
Explanations: 
ls -lh (lists all files)
sed -n  '/Oct\ 21\ 16:30/p' (find files at given date from list)
awk '{print $9}' (print only file names on list) and >> 1.txt put list of files to 1.txt
rm -f (force to delete)

Wednesday, October 14, 2009

Recursively Download FTP

Sometimes, you may need to move one server to another. At that time, you may use wget command to move your files without any pain.
Here is the command for recursive download on ftp via wget:

wget -r ftp://username:password@ftp.example.com/
Yes, thats all folks!

Thursday, October 8, 2009

List of users on Linux

To list the users in linux you may use following command:

cat /etc/passwd | cut -d ":" -f1