Skip to main content

Posts

Showing posts from November, 2017

APACHE REVERSE PROXY WITH MOD_PROXY MODULE ON CENTOS 7

A reverse proxy is a type of proxy server that takes HTTP/HTTPS requests and distributes it to one or more backend servers. Reverse proxies are useful because many modern web applications process incoming HTTP requests using backend application servers which aren't meant to be directly accessed by user. First install httpd #yum install httpd Open /etc/httpd/conf/httpd.conf and check mod_proxy and related modules is enabed.Defaultly they will be enabled.Some of mod_proxy modules are: >mod_proxy, the main proxy module Apache module for redirecting connections; it allows Apache to act as a gateway to the underlying application servers. >mod_proxy_http, which adds support for proxying HTTP connections. >mod_proxy_balancer and mod_lbmethod_byrequests, which add load balancing features for multiple backend servers. Use httpd -M command to check it #httpd -M We can see they are defaulty enabled. Reverse proxying a single backend server #cd /etc/httpd/conf.d/ #vi default-si

IP ALIASING -CREATING OR ADDING NEW NETWORK ALIAS TO A NETWORK CARD

Centos: In linux we can add multiple ip to a single nic card. #cd /etc/sysconfig/network-scripts/ #vi ifcfg-eth0 #cp ifcfg-eth0 ifcfg-eth0:1 Change the ip,device Similarly for third ip again copy ifcfg-eth0 as ifcfg-eth0:2 and make necessary changes inside file as above. #service network restart #ifconfig. Now we can see multiple ip assigned to it Ubuntu: In ubuntu the network configuration file is /etc/network/interfaces.Open it and make necessary changes as follows #vi /etc/network/interfaces The default file will be as follows: Make changes to obtain configuration as follows #service networking restart

VIRTUAL HOSTING ON UBUNTU 16

Mainly there are 2 types of virtual hosting: name based and ip based virtual hosting. With the name based virtual hosting you can host several domains/websites on a single machine with a single IP. All domains on that server will be sharing a single IP. With the IP based virtual hosting, you can assign a separate IP for each domain on a single server, these IP’s can be attached to the server with single NIC cards and as well as multiple NICs. Name based Virtual Hosting: First update and then install apache2 package #apt-get update #apt-get install apache2 #service start apache2 #cd /var/www/html Create test1 and test2 folders where we host our websites #mkdir test1.com #cd test1.com && vi index.html Enter the following html code there <html>   <head>     <title>Welcome to test1.com!</title>   </head>   <body>     <h1>Success!  The test1.com virtual host is working!</h1>   </body> </html> Now create a directory for se

RECOVERING ROOT PASSWORD IN UBUNTU 16

There are many ways to reset root password if we forget it.Some of ways are: On booting press e.It will take us to edit mode On the end of line bigining with linux type Rw init=/bin/bash Press cntrl+X to reboot   On the screen that appears set password for root #passwd root #exec /sbin/init (This will reboot the machine) Now your password is reset Other method : On booting go to recovery mode and press e Press tab key From the screen that appers select root shell #mount -o rw,remount / #passwd root Thus set password for root and reboot

SETTING STATIC IP IN SUSE 11

To set static ip we can use yast command #yast From the table that appears select Network services > Network settings Go to address and set ip,netmask and hostname Then from Hostname/DNS give hostname and nameserver details  Then from Routing give gateway Afterthat click ok and restart network service #service network restart (note:the configuration file is /etc/sysconfig/network/ifcfg- interfacename)

LEMP ON CENTOS 6.9

LEMP is a combination of operating system and open-source software stack. The acronym LEMP is derived from first letters of Linux, Nginx HTTP Server, MariaDB database, and PHP/Perl/Python First install epel-relese package #yum install epel-release Now install nginx # yum install nginx -y # service nginx start # vi /etc/nginx/nginx.conf worker_processes 1; # vi /etc/nginx/conf.d/default.conf -------------------------------------------------------------------------- server  {     listen       80;     server_name  your sever ip;     #charset koi8-r;     #access_log  logs/host.access.log  main;     location / {         root   /usr/share/nginx/html;         index  index.html index.htm;     }     error_page  404              /404.html;     location = /404.html {         root   /usr/share/nginx/html;     }     # redirect server error pages to the static page /50x.html     #     error_page   500 502 503 504  /50x.html;     location = /50x.html {         root   /usr

VSFTPD SERVER WITH MULTIPLE USERS ABLE TO ACESS SHARED FOLDER

First install vsftpd package #yum install vsftpd -y Open vsftpd configuration file and the check the directives is as follows(if not present add it) #vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO  (restricting anonymous users) local_enable=YES (When enabled, local users are allowed to log into the system.) local_root=/test (this mention the root directory of ftp server) pasv_promiscuous=YES (if gave no the ftp server will checks wheather the client is connecting to transfer port and control port is same and if we give yes it will not check ) Now start the service #service vsftpd start create directory #mkdir /test create a group which have acess to out ftp directory #groupadd ftpgroup create a user with no shell login and home directory /test under ftpgroup #useradd -g ftpgroup -s /sbin/nologin ftpuser1 #useradd -g ftpgroup -s /sbin/nologin ftpuser2 set password for ftpuser1 and ftpuser2 #password ftpuser1 #chmod 775 /test #chown ftpuser1:ftpgroup /test Now

HAPROXY LOADBALENCER FOR HTTPD ON CENTOS 7

HAProxy(High Availability Proxy) is an open-source load-balancer whisch is is free,fast and reliable. It offers load-balancing, high-availability, and proxying for TCP and HTTP-based applications.Here we are using it for loadbalencing httpd.Here we are configuring haproxy server assuming that we have httpd installed on our two nodes. First install the dependencies #yum install gcc pcre-static pcre-devel -y Download the ha-proxy package #wget https://www.haproxy.org/download/1.7/src/haproxy-1.7.8.tar.gz Extract it #tar -xvzf haproxy.tar.gz #cd haproxy-1.7.8 then ensure you compile the program for your system. #make TARGET=linux2628 #make install Setting up HAProxy for your server Create the following directories #mkdir -p /etc/haproxy #mkdir -p /run/haproxy #mkdir -p /var/lib/haproxy #touch /var/lib/haproxy/stats Make a symbolic link so the binary will allow you to run HAProxy commands as a normal user. ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy copy the i