Posts

Basic security for Apache

At production environment, it is not wise to show Apache server version. Edit /etc/httpd/conf/httpd.conf ServerSignature Off ServerTokens Prod TraceEnable off sed -i -e '/ServerSignature/ s/On/Off/' /etc/httpd/conf/httpd.conf sed -i -e '/ServerTokens/ s/OS/Prod/' /etc/httpd/conf/httpd.conf echo "TraceEnable off" >> /etc/httpd/conf/httpd.conf

How to setup squid proxy server

This note provides how to setup squid proxy service. Install squid proxy yum -y install squid Allow access sed -i -e '/http_access allow/a #Allow access for localnet\nhttp_access allow localnet' /etc/squid/squid.conf Change port to 8080 sed -i -e '/http_port/ s/3128/8080/g' /etc/squid/squid.conf Other tuning parameters cat >> /etc/squid/squid.conf <<EOF request_header_access Referer deny all request_header_access X-Forwarded-For deny all request_header_access Via deny all request_header_access Cache-Control deny all visible_hostname webproxy.infotheater.net forwarded_for on EOF Open firewall sed -i -e '/#Add custom rules below/a #Squid proxy\n-A INPUT -m state --state NEW -p tcp --dport 8080 -j ALLOWED_IPS' /etc/sysconfig/iptables service iptables reload Make sure service start upon system startup chkconfig squid on service squid start Install squid report-lightsquid service yum -y install lightsquid lightsquid-apache Open...

Mail server setup with postfix

This article provides steps to install complete mail server environment. Install CentOS6 with minimal installation Disable selinux sed -i -e 's/enforcing/disabled/' /etc/sysconfig/selinux Import GPG keys rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* Enable RPMforge rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm Enable EPEL rpm --import https://fedoraproject.org/static/0608B895.txt wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm Install yum-porities (Important to overcome package conflict) yum install yum-priorities Set EPEL to priority 10 [epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=e...

OpenVZ operation commands

This note includes useful commands to adjust guest OS resources allocation at OpenVZ environment. Monitor kmemsize usages cat /proc/user_beancounters Version: 2.5 uid resource held maxheld barrier limit failcnt vm01: kmemsize 836919 1005343 2752512 2936012 0 May increase the barrier and limit vzctl set vm01 --kmemsize [barrier in number]:[limit in number] --save Validate config vzcfgvalidate /etc/vz/conf/vm01.conf Monitor Disk usage vzquota stat vm01 resource usage softlimit hardlimit grace 1k-blocks 327664 1048576 1153434 inodes 18857 200000 220000 Increase diskspace vzctl set vm01 --diskspace 20G:25G --save Increase double of inodes vzctl set vm01 --diskinodes $(( 200000*2 )):$(( 220000*2 )) --save Set CPU allocation vzctl set vm01 --cpuunits 1000 --save vzctl set vm02 --cpuunits 1000 --save vzctl set vm03 --cpuunits 200...

Encrypt file with OpenSSL

To encrypt a file using AES with a 256 bit key-length: openssl enc -e -aes-256-cbc -salt -in filename.odp -out filename.odp.enc To decrypt the file: openssl enc -d -aes-256-cbc -in filename.odp.enc -out filename.odp

How to setup JBoss Apache mod_jk

This note provides typical setup steps for Jboss application server. Initial setup Install Java Install apache-ant (Just need to extract the zip) Configure environment variable For example /root/.bash_profile ANT_HOME=/opt/ant PATH=/opt/java/bin:$ANT_HOME/bin:$PATH:$HOME/bin:./ JAVA_HOME=/opt/java export JAVA_HOME export PATH export CLASSPATH=/usr/java/jdk/lib/tools.jar:/usr/java/jdk/jre/lib/rt.jar:./ Install jboss GA version http://sourceforge.net/projects/jboss   Unzip it at /opt directory Configure environment variable /root/.bash_profile JBOSS_HOME=/opt/jboss export JBOSS_HOME Write init script to start Startup nohup /opt/jboss/bin/run.sh -b 0.0.0.0 & Shutdown opt/jboss/bin/shutdown -S Install mod_jk for apache proxying http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux Copy mod_jk.so to /etc/httpd/modules Edit httpd.config for mod_jk vi /etc/httpd/conf/httpd.conf Include conf/mod_jk.conf Create /etc/httpd/conf/mod_jk.c...

Web load balancer with HAproxy

This note provides steps for up and running haproxy loadbalancer for http service. Install haproxy rpm yum install haproxy Edit haproxy.cfg vi /etc/haproxy/haproxy.cfg global maxconn 100000 user haproxy group haproxy defaults #log global mode http # option httplog # option dontlognull retries 3 option redispatch maxconn 100000 contimeout 5000 clitimeout 50000 srvtimeout 50000 VIP address. Do not add config at /etc/sysctl.conf listen webfarm 192.168.1.3:80 It can be tcp or http mode http # stats enable # stats auth someuser:somepassword balance roundrobin # allow to track source ip option forwardfor option httpchk HEAD /linkcheck.html HTTP/1.0 server webA 192.168.1.1:80 cookie A check server webB 192.168.1.2:80 cookie B check Edit system parameter vi /etc/sysctl.conf net.ipv4.ip_nonlocal_bind = 1