August 2025
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

August 2025
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

Nginx server security configuration

Nginx server security configuration

First, turn off SELinux
Security-Enhanced Linux (SELinux) is a Linux kernel feature that provides security policy protection mechanism supports access control.
However, SELinux brings additional security and the disproportionate use of complexity, cost is not high

sed -i /SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config

/usr/sbin/sestatus -v # Check status

Second, the least privilege allowed by zoning mount

A separate partition on the server nginx directory.

For example, create a new partition /dev/sda5 (first logical partition), and mounted at /nginx.
Make sure /nginx is noexec,nodev and nosetuid permission to mount

The following is my /etc/fstab mount /nginx information: LABEL=/nginx /nginx ext3 defaults,nosuid,noexec,nodev 1 2

Note: You need to create a new partition using fdisk and mkfs.ext3 command.
Third, to strengthen the Linux security configuration /etc/sysctl.conf

You can control and configure the Linux kernel by editing /etc/sysctl.conf, network settings

# Avoid a smurf attack

net.ipv4.icmp_echo_ignore_broadcasts = 1

# Turn on protection for bad icmp error messages

net.ipv4.icmp_ignore_bogus_error_responses = 1

# Turn on syncookies for SYN flood attack protection

net.ipv4.tcp_syncookies = 1

# Turn on and log spoofed, source routed, and redirect packets

net.ipv4.conf.all.log_martians = 1

net.ipv4.conf.default.log_martians = 1

# No source routed packets here

net.ipv4.conf.all.accept_source_route = 0

net.ipv4.conf.default.accept_source_route = 0

# Turn on reverse path filtering

net.ipv4.conf.all.rp_filter = 1

net.ipv4.conf.default.rp_filter = 1

# Make sure no one can alter the routing tables

net.ipv4.conf.all.accept_redirects = 0

net.ipv4.conf.default.accept_redirects = 0

net.ipv4.conf.all.secure_redirects = 0

net.ipv4.conf.default.secure_redirects = 0

# Don’t act as a router

net.ipv4.ip_forward = 0

net.ipv4.conf.all.send_redirects = 0

net.ipv4.conf.default.send_redirects = 0

# Turn on execshild

kernel.exec-shield = 1

kernel.randomize_va_space = 1

# Tuen IPv6

net.ipv6.conf.default.router_solicitations = 0

net.ipv6.conf.default.accept_ra_rtr_pref = 0

net.ipv6.conf.default.accept_ra_pinfo = 0

net.ipv6.conf.default.accept_ra_defrtr = 0

net.ipv6.conf.default.autoconf = 0

net.ipv6.conf.default.dad_transmits = 0

net.ipv6.conf.default.max_addresses = 1

# Optimization for port usefor LBs

# Increase system file descriptor limit

fs.file-max = 65535

# Allow for more PIDs (to reduce rollover problems); may break some programs 32768

kernel.pid_max = 65536

# Increase system IP port limits

net.ipv4.ip_local_port_range = 2000 65000

# Increase TCP max buffer size setable using setsockopt()

net.ipv4.tcp_rmem = 4096 87380 8388608

net.ipv4.tcp_wmem = 4096 87380 8388608

# Increase Linux auto tuning TCP buffer limits

# min, default, and max number of bytes to use

# set max to at least 4MB, or higher if you use very high BDP paths

# Tcp Windows etc

net.core.rmem_max = 8388608

net.core.wmem_max = 8388608

net.core.netdev_max_backlog = 5000

net.ipv4.tcp_window_scaling = 1

Fourth, remove all unnecessary Nginx module

You need to make the number of modules directly by compiling the source code Nginx minimized. By limiting access to only allow web server module to minimize risk.
You can configure only install nginx modules you need. For example, disabling SSL and autoindex module you can execute the following command:

./configure -without-http_autoindex_module -without-http_ssi_module
make && make install

Change nginx version name, edit the file /h/http/ngx_http_header_filter_module.c?

vim  src/http/ngx_http_header_filter_module.c

static char ngx_http_server_string[] = “Server: nginx” CRLF;

static char ngx_http_server_full_string[] = “Server: ” NGINX_VER CRLF;

//change to

static char ngx_http_server_string[] = “Server: Mohan Web Server” CRLF;

static char ngx_http_server_full_string[] = “Server: Mohan Web Server” CRLF;

Close nginx version number display

server_tokens off

Fifth, based Iptables firewall restrictions

The following firewall script block any addition to allowing:

HTTP (TCP port 80) of a request from
ICMP ping requests from
ntp (port 123) requests output
smtp (TCP port 25) request output

Six control buffer overflow attacks

Edit and set all clients buffer size limit is as follows:

client_body_buffer_size  1K;

client_header_buffer_size 1k;

client_max_body_size 1k;

large_client_header_buffers 2 1k;

client_body_buffer_size 1k (default 8k or 16k) This instruction can specify the buffer size of the connection request entity.
If the value exceeds the specified buffer connection request, then the whole or part of the requesting entity will try to write a temporary file.
client_header_buffer_size 1k  directive specifies the client request buffer size of the head.
In most cases a request header is not greater than 1k, but if there is a large cookie wap from the client that it may be greater than 1k,
Nginx will assign it a larger buffer, this value can be set inside the large_client_header_buffers .
client_max_body_size 1k- directive specifies the maximum allowable size of the client requesting entity connected, it appears in the Content-Length header field of the request.

If the request is greater than the specified value, the client will receive a “Request Entity Too Large” (413) error. Remember, the browser does not know how to display the error.
large_client_header_buffers- specify the client number and size of some of the larger buffer request header use.
Request a field can not be greater than the buffer size, if the client sends a relatively large head, nginx returns “Request URI too large” (414)
Similarly, the head of the longest field of the request can not be greater than one buffer, otherwise the server will return “Bad request” (400). Separate buffer only when demand.
The default buffer size for the operating system paging file size is usually 4k or 8k, if a connection request is ultimately state to keep- alive, it occupied the buffer will be freed.

You also need to improve server performance control timeouts and disconnects the client. Edit as follows:

client_body_timeout 10;
client_header_timeout 10;
keepalive_timeout 5 5;
send_timeout 10;

• client_body_timeout 10; – directive specifies the timeout request entity read. Here timeout refers to a requesting entity did not enter the reading step, if the connection after this time the client does not have any response, Nginx will return a “Request time out” (408) error.
• client_header_timeout 10; – directive specifies the client request header headline read timeout. Here timeout refers to a request header did not enter the reading step, if the connection after this time the client does not have any response, Nginx will return a “Request time out” (408) error.
• keepalive_timeout 5 5; – the first parameter specifies the timeout length of the client and server connections, over this time, the server will close the connection. The second parameter (optional) specifies the response header Keep-Alive: timeout = time value time, this value can make some browsers know when to close the connection to the server not repeat off if you do not specify this parameter , nginx does not send Keep-Alive header information in the response. (This does not refer to how a connection “Keep-Alive”) These two values ??of the parameters can be different.
• send_timeout 10; directive specifies the timeout is sent to the client after the response, Timeout refers not enter a complete state established, completed only two handshakes, more than this time if the client does not have any response, nginx will close the connection.

Seven control concurrent connections

You can use NginxHttpLimitZone module to restrict a specific session or a special case of concurrent connections IP addresses under. Edit nginx.conf:

### Directive describes the zone, in which the session states are stored i.e. store in slimits. ###

### 1m can handle 32000 sessions with 32 bytes/session, set to 5m x 32000 session ###

limit_zone slimits $binary_remote_addr 5m;

### Control maximum number of simultaneous connections for one session i.e. ###

### restricts the amount of connections from a single ip address ###

limit_conn slimits 5

The above represents the remote IP address to limit each client connection can not be open at the same time more than five.

Eight, only allow access to our domain

If the robot is just random scan all domain name servers, that reject the request. You must allow the configuration of the virtual domain or reverse proxy request. You do not use IP addresses to reject.

if ($host !~ ^(test.in|www.test.in|images.test.in)$ ) {
return 444;
}

Nine, to limit the request method available

GET and POST are the Internet’s most commonly used method. The method of the Web server is defined in RFC 2616. If the Web server is not required to run all available methods, they should be disabled. The following command will filter only allows GET, HEAD and POST methods:

## Only allow these request methods ##

if ($request_method !~ ^(GET|HEAD|POST)$ ) {

return 444;

}

## Do not accept DELETE, SEARCH and other methods ##

More about HTTP method introduced

• GET method is used to request,

• HEAD method is the same, unless GET request to the server can not return the message body.

• POST method can involve many things, such as storage or update data, or ordering products, or send e-mail by submitting the form. This is usually the use of server-side processing, such as PHP, Perl and Python scripts. If the file you want to upload and server processing the data, you must use this method.

Ten, how to refuse a number of User-Agents?

You can easily stop User-Agents, such as scanners, robotics and abuse your server spammers.

## Block download agents ##

if ($http_user_agent ~* LWP::Simple|BBBike|wget) {

return 403;

}

Soso and the proper way to prevent robots:

## Block some robots ##

if ($http_user_agent ~* Sosospider|YodaoBot) {

return 403;

}

XI prevent image hotlinking

Pictures or HTML Daolian mean someone directly with your website address to display pictures on his website. The end result, you need to pay the extra cost of broadband. This is often in the forum and blog. I strongly recommend that you block and prevent hotlinking behavior.

# Stop deep linking or hot linking

location /images/ {

valid_referers none blocked www.example.com example.com;

if ($invalid_referer) {

return  403;

}

}

For example: the redirect and display the specified image

valid_referers blocked www.example.com example.com;

valid_referers blocked www.example.com example.com;

if ($invalid_referer) {

rewrite ^/images/uploads.*\.(gif|jpg|jpeg|png)$ http://www.examples.com/banned.jpg last

}

Twelve, directory restrictions

You can set access permissions on the specified directory. All websites directory should one configuration, allowing only access to the directory.
Access by IP address restrictions
You can restrict access by IP address directory / admin /:

ocation /docs/ {

## block one workstation

deny    192.168.1.1;

## allow anyone in 192.168.1.0/24

allow  192.168.1.0/24;

## drop rest of the world

deny    all;

}

Via password protected directory, first create the password file and increase the “user” user

mkdir /usr/local/nginx/conf/.htpasswd/

htpasswd -c /usr/local/nginx/conf/.htpasswd/passwd user

Edit nginx.conf, added need protected directories

### Password Protect /personal-images/ and /delta/ directories ###

location ~ /(personal-images/.*|delta/.*) {

auth_basic  “Restricted”;

auth_basic_user_file  /usr/local/nginx/conf/.htpasswd/passwd;

}

Once the password file has been generated, you can also use the following command to allow access to the user increases

htpasswd -s /usr/local/nginx/conf/.htpasswd/passwd userName

Thirteen, Nginx SSL Configuration

HTTP is a plain text protocol, which is open to passive surveillance. You should use SSL to encrypt your user content.
Create SSL certificate, execute the following command:

cd /usr/local/nginx/conf

openssl genrsa -des3 -out server.key 1024

openssl req -new -key server.key -out server.csr

cp server.key server.key.org

openssl rsa -in server.key.org -out server.key

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Edit nginx.conf press following updates:

server {

server_name example.com;

listen 443;

ssl on;

ssl_certificate /usr/local/nginx/conf/server.crt;

ssl_certificate_key /usr/local/nginx/conf/server.key;

access_log /usr/local/nginx/logs/ssl.access.log;

error_log /usr/local/nginx/logs/ssl.error.log;

}

Fourteen, Nginx and PHP Security Recommendations

PHP is a popular scripting language on the server side. Edit /etc/php.ini file as follows:

# Disallow dangerous functions

disable_functions = phpinfo, system, mail, exec

## Try to limit resources  ##

# Maximum execution time of each script, in seconds

max_execution_time = 30

# Maximum amount of time each script may spend parsing request data

max_input_time = 60

# Maximum amount of memory a script may consume (8MB)

memory_limit = 8M

# Maximum size of POST data that PHP will accept.

post_max_size = 8M

# Whether to allow HTTP file uploads.

file_uploads = Off

# Maximum allowed size for uploaded files.

upload_max_filesize = 2M

# Do not expose PHP error messages to external users

display_errors = Off

# Turn on safe mode

safe_mode = On

# Only allow access to executables in isolated directory

safe_mode_exec_dir = php-required-executables-path

# Limit external access to PHP environment

safe_mode_allowed_env_vars = PHP_

# Restrict PHP information leakage

expose_php = Off

# Log all errors

log_errors = On

# Do not register globals for input data

register_globals = Off

# Minimize allowable PHP post size

post_max_size = 1K

# Ensure PHP redirects appropriately

cgi.force_redirect = 0

# Disallow uploading unless necessary

# Enable SQL safe mode

sql.safe_mode = On

# Avoid Opening remote files

allow_url_fopen = Off

Fifth, if possible, let Nginx run in a chroot jail

The nginx placed in a chroot jail to reduce the potential for illegal entry into other directories. You can use the traditional and nginx installed with chroot. If possible, that use FreeBSD jails, Xen, OpenVZ virtualization container concept.

XVI firewall level limits the number of connections for each IP

Network server must monitor connections and connection limits per second. PF and Iptales are able to enter your nginx server before the end user to block access.
Linux Iptables: limit the number of connections for each Nginx
following example will prevent from a single IP connection of more than 15 the number of ports 80, 60 seconds.

/sbin/iptables -A INPUT -p tcp –dport 80 -i eth0 -m state –state NEW -m recent –set

/sbin/iptables -A INPUT -p tcp –dport 80 -i eth0 -m state –state NEW -m recent –update –seconds 60  –hitcount 15 -j DROP

service iptables save

According to your specific situation to set the connection limit.

XVII configure the operating system to protect Web servers

Like the above described start SELinux Correct set permissions /nginx document root directory.
Nginx running in user nginx. But the root directory (/ nginx or /usr/local/nginx/html/) should not be set, or the user belongs to the user nginx nginx writable.
Find the error file permissions can use the following command:

find /nginx -user nginx

find /usr/local/nginx/html -user nginx

Make sure you are more ownership of the root or other users, a typical permission settings /usr/local/nginx/html/

ls -l /usr/local/nginx/html/

Sample output:

-rw-r-r- 1 root root 925 Jan 3 00:50 error4xx.html

-rw-r-r- 1 root root 52 Jan 3 10:00 error5xx.html

-rw-r-r- 1 root root 134 Jan 3 00:52 index.html

You must delete the backup files from the vi or another text editor to create:

find /nginx -name ‘.?*’ -not -name .ht* -or -name ‘*~’ -or -name ‘*.bak*’ -or -name ‘*.old*’

find /usr/local/nginx/html/ -name ‘.?*’ -not -name .ht* -or -name ‘*~’ -or -name ‘*.bak*’ -or -name ‘*.old*’

To delete these files by -delete option to find command.

Eighth, the outgoing connections limit Nginx

Hackers can use tools such as wget download your local file server. Iptables from using nginx user to block outgoing connections. ipt_owner module tries to match the creator of locally generated packets. The following example allows only users 80 user connections outside.

/sbin/iptables -A OUTPUT -o eth0 -m owner –uid-owner vivek -p tcp –dport 80 -m state –state NEW,ESTABLISHED  -j ACCEPT

With the above configuration, your nginx server is already very safe and you can publish web pages. However, you should also find more information on security settings according to your site procedures. For example, wordpress or a third-party program.

Login problem on Zimbra web http (cookies)

Si vous avez ce message d’erreur sur Zimbra voilà la marche à suivre :

/opt/zimbra/libexec/zmproxyconfig -e -w -o -a 8080:80:8443:443 -x both -H `zmhostname`

Si vous avez une erreur à cette commande là, lancer ensuite celle là :

zmprov ms `zmhostname` zimbraReverseProxySSLToUpstreamEnabled FALSE

Puis relancer la commande précédente et enfin les commandes suivantes :

zmtlsctl both
zmprov ms `zmhostname` zimbraReverseProxyMailMode both
zmprov ms `zmhostname` zimbraMailMode both
zmcontrol restart

 

su “zimbra”
zmprov ms `zmhostname` zimbraReverseProxySSLToUpstreamEnabled FALSE
zmcontrol stop
zmcontrol start

 

Rename Root Volume Group (VG) on Linux Server

This walk-through worked on a virtual server running RHEL 6.7 in a VMware environment.

As I rebuilt an existing VMware guest that was being scheduled to go into production, I realized I did not rename the default volume group from vg_hostname to rootvg.

You must be root user and it is extremely important to backup the files below. It’s also important to know how to boot up in rescue mode with other boot media in the event there was a typo or other unforeseen issue.

Backup fstab file

cp /etc/fstab /etc/fstab.orig

Backup grub.conf file

cp /boot/grub/grub.conf /boot/grub/grub.conf.orig

Rename volume group

vgrename /dev/vg_OLDname /dev/rootvg

Change all instances of the old volume group in the following files:
Edit /etc/grub.conf (which is a symbolic link to /boot/grub/grub.conf)

vim /etc/grub.conf

Search and replace

:%s/vg_OLDname/rootvg/g

Edit fstab file

vim /etc/fstab

Search and replace

:%s/vg_OLDname/rootvg/g

Move boot image

mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.backup
dracut -v /boot/initramfs-$(uname -r).img $(uname -r)

Verify your work
Reboot

Disable IPv6 In CentOS 7

entOS Linux release 7.0.1406 (Core)

Verify Centos Version
cat /etc/centos-release

I’ve discovered bugs in some install packages. One such package is Zimbra. To work around these bugs, IPv6 and associated dependencies need to be disabled.

To disable IPv6 in a CentOS 7 installation, perform the following tasks:

Task 1
Navigate to and create a file inside/etc/modprobe.d/.
(The name of the file can be anything, I chose “disable-ipv6”)
cd /etc/modprobe.d/
nano disable-ipv6
Add this line
install ipv6 /bin/true
Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

Task 2
Comment Out Hosts Entry
nano /etc/hosts
By default, this is what’s present:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Comment out
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

Task 3
Reboot the system to complete the process. It is required.

Zimbra 8.6 on Linux CentOS 7.0

Configure DNS Entries on your local DNS server
Setup DNS A Record
Ensure you have a Reverse lookup zone
Setup MX Record

Configure Host Settings
Login as root user
su root

Install pre-requisites
yum install wget make nc sudo sysstat libtool-ltdl glibc perl-core ntp unzip libaio

Set hostname
hostname mail.yourdomain.com

Edit hostname file
nano /etc/hostname
mail.yourdomain.com

Add Hosts Entries
nano /etc/hosts

By default, this is what’s present:
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Comment out (required for disabling ipv6)
#::1               localhost localhost.localdomain localhost6 localhost6.localdomain6

Add the following:
<server IP>   mail.yourdomain.com MAIL
<local DNS IP> mail.yourdomain.com

Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

 

Disable other services and firewall
service postfix stop
chkconfig postfix off
service ip6tables stop
chkconfig ip6tables off

 

Disable SELINUX
Enter this at command line:
setenforce 0

Update selinux config file
nano /etc/selinux/config
selinux=permissive

Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

 

Completely disable the ipv6 module
To completely disable IPv6 in your system, all you have to do is save the following line in a file inside/etc/modprobe.d/.
cd /etc/modprobe.d/
nano disable-ipv6

Add this to the new file:
ipv6 /bin/true

Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

 

Configure iptables to allow email server traffic
nano /etc/sysconfig/iptables

Add the following

-A INPUT -m state –state NEW -m tcp -p tcp –dport 25 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 110 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 143 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 443 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 389 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 465 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 993 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 995 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 7071 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 7025 -j ACCEPT

Press “Ctl+X” to exit
Select “Y” to save changes
Press “Enter” to get back to CL

 

Download Zimbra Installation
Latest Version 8.6.0 GA Release
http://www.zimbra.com/downloads/zimbra-collaboration-open-source

 

Move Zimbra Download File To New VM
I downloaded the package to my local Windows workstation. From a Windows machine, an additional tool is required.  There are a few options but I downloaded and used WinSCP v 5.5.2. It works.

Copy downloaded Zimbra .tgz file (in this case zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz) from local workstation to /tmp/ directory on new VM. Simple click, drag and drop copies the file.

 

Decompress and Install Zimbra
From the CL, decompress the file by running the following command:
tar xzf zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz

 

Navigate to the newly created/renamed directory:
cd zcs-8.6.0_GA_1153.RHEL7_64.20141215151110

su root
./install.sh

To uninstall (which you will need to do if you run into issues with the installation)
./install.sh -u

 

Change admin password to a more complex password  (this is the admin console login)
“r” to return to previous screen
“a” to apply the changes
Yes to save config to file
Enter to save to default config file
Yes to modify system

Save config in file: [/opt/zimbra/config.23168]
Moving /tmp/zmsetup01072015-114839.log to /opt/zimbra/log

When complete, change user to zimbra
su – zimbra

Check status of Zimbra
zmcontrol status

 

Verify Mail Server is Operational
Open a browser and navigate to https://mail.yourdomain.com (webmail console)

Login using admin and password

 

Open a browser and navigate to https://mail.yourdomain.com:7071 (admin console)
Login using admin and password

 

Once logged into your admin panel, continue configuration
Configure->Global Settings->MTA

Add hostname of your server (in this case, mail)

Added New Domain yourdomain.com

Setup admin@yourdomain.com with Global Admin rights

Deleted domain created at setup mail.yourdomain.com

Create user accounts

Create distribution lists

Create aliases

 

Production

To put this server into production, you will need to:
1. Contact your ISP and request a PTR record or reverse DNS.
2. Acquire a certificate from a trusted source.
3. Setup an MX record with your domain registrar

 

Customizations
Rebranding is limited with the OSS license. Ensure your read and understand the licensing agreement.

Favicon Locations
/opt/zimbra/jetty-distribution-9.1.5.v20140505/webapps/zimbraAdmin/img/logo/favicon.ico
/opt/zimbra/jetty-distribution-9.1.5.v20140505/webapps/zimbra/img/logo/favicon.ico

 

Changing the Page Title

As zimbra user (su – zimbra):
vi /opt/zimbra/jetty/webapps/zimbra/WEB-INF/classes/messages/ZmMsg.properties
[change value for zimbraTitle = <new value>]
vi /opt/zimbra/jetty/webapps/zimbra/WEB-INF/classes/messages/ZhMsg.properties
[change value for zimbraTitle = <new value>]

The first is for the advanced client and the second is for the basic client.
You will need to restart jetty and clear your browser cache/restart browser to see change take effect

As zimbra user,
zmmailboxdctl restart

Centos 6.7 apache2.4.x

Centos 6.7 apache2.4.x compile and install and configure virtual hosts, SSL access, user-based access control

apache2.4 new features

Loadable MPMs
At compile time can be made ??of a plurality of removable of MPM. The choice of MPM can also be configured at run time.

Event MPM
full support Event MPM. This is just test version of Apache 2.2.
Asynchronous support
better asynchronous read / write support in support of MPM and platforms.
Per-module and per-directory LogLevel configuration
LogLevel can be set different for different modules and directories.
On debug logging levels to increase the trace1 trace8 tracking method.
Per-Request configuration Sections
<If>, <ElseIf>, and <Else> block can be used in every request can be set on the configuration level.
General-purpose expression parser
new expression parser allows the instruction (eg SetEnvIfExpr, RewriteCond, Header, <If>, etc.)
using a common syntax to specify complex criteria.

KeepAliveTimeout in milliseconds
now in milliseconds (milliseconds) Set the connection holding time (KeepAliveTimeout).
NameVirtualHost directive is no longer needed, it has been deprecated.
Override Configuration
AllowOverrideList allow new directory (.htaccess allowed directory) a more fine-grained control.
Config file variables
can now define and use variables in the configuration file.

Reduced memory usage though adds many new features, version 2.4.x Apache was successfully reduced memory footprint (compared to 2.2.x version).

Ready to work

Before compiling still need to do some preparation. 1, if there apache2.2.x apache2.2.x then we need to deactivate and remove it before you start automatically on a server 2,
apache2.4.x dependent apr also requires version 1.4 or more, so before compiling further QPR need to compile high version 3, making apache2.4.x available boot startup scripts and configuration, etc.

yum groupinstall “Development tools” “Server Platform Development” -y

service httpd stop
chkconfig httpd off
chkconfig –list | grep httpd

Two, apr> = 1.4 version of the compiler

wget http://www.us.apache.org/dist//apr/apr-1.5.2.tar.gz
wget http://www.us.apache.org/dist//apr/apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
tar -zxvf apr-1.5.2.tar.gz

cd /root/software/apr-1.5.2
./configure –prefix=/usr/local/apr1.5.2
make && make install

cd /root/software/apr-util-1.5.4
./configure –prefix=/usr/local/aprutil154 –with-apr=/usr/local/apr1.5.2
make && make install

wget http://www.us.apache.org/dist//httpd/httpd-2.4.18.tar.gz
cd /root/software/httpd-2.4.18

./configure –prefix=/usr/local/apache2418 –sysconfdir=/etc/httpd2418 –enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr1.5.2 –with-apr-util=/usr/local/aprutil154 –enable-mpms-shared=all –with-mpm=event –enable-modules=most
make  &&  make install

checking for pcre-config… false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@cluster1 httpd-2.4.18]#

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

yum install pcre-devel -y

echo “export PATH=/usr/local/apache2418/bin/:\$PATH”

/etc/profile.d/apache2418.sh

sed -i “$(awk ‘$1==”MANPATH”{i=NR}END{print i}’ /etc/man.config)a \MANPATH\tMANPATH /usr/local/apache2418/man” /etc/man.config

ln -s /usr/local/apache2418/include/ /usr/include/apache

[root@cluster1 ~]# man httpd

[root@cluster1 bin]# ./apachectl -v
Server version: Apache/2.4.18 (Unix)
Server built:   Jan 10 2016 22:52:22
[root@cluster1 bin]#

[root@cluster1 bin]# ss -utnl
Netid  State      Recv-Q Send-Q                                  Local Address:Port                                    Peer Address:Port
udp    UNCONN     0      0                                                   *:40459                                              *:*
udp    UNCONN     0      0                                                   *:935                                                *:*
udp    UNCONN     0      0                                           127.0.0.1:979                                                *:*
udp    UNCONN     0      0                                                   *:111                                                *:*
udp    UNCONN     0      0                                        192.168.1.60:123                                                *:*
udp    UNCONN     0      0                                           127.0.0.1:123                                                *:*
udp    UNCONN     0      0                                                   *:123                                                *:*
udp    UNCONN     0      0                                                  :::935                                               :::*
udp    UNCONN     0      0                                                  :::60761                                             :::*
udp    UNCONN     0      0                                                  :::111                                               :::*
udp    UNCONN     0      0                                                 ::1:123                                               :::*
udp    UNCONN     0      0                                                  :::123                                               :::*
tcp    LISTEN     0      128                                                 *:55775                                              *:*
tcp    LISTEN     0      128                                                :::111                                               :::*
tcp    LISTEN     0      128                                                 *:111                                                *:*
tcp    LISTEN     0      128                                                :::80                                                :::*
tcp    LISTEN     0      128                                                :::22                                                :::*
tcp    LISTEN     0      128                                                 *:22                                                 *:*
tcp    LISTEN     0      100                                               ::1:25                                                :::*
tcp    LISTEN     0      100                                         127.0.0.1:25                                                 *:*
tcp    LISTEN     0      128                                                :::38427                                             :::*
[root@cluster1 bin]# ss -utnl | grep 80
tcp    LISTEN     0      128                   :::80                   :::*
[root@cluster1 bin]#

for I in $(ps aux | grep [h]ttp |awk ‘{print$2}’); do kill -9 $I;done
for I in $(ps aux | grep [a]pache |awk ‘{print$2}’); do kill -9 $I;done

cp /usr/local/apache2418/bin/apachectl /etc/init.d/httpd

sed -i ‘/#!\/bin\/sh/a \# chkconfig: 35 85 15\n# description: Activates\/Deactivates Apache 2.4.18’ /etc/init.d/httpd

chkconfig –add httpd
chkconfig –list httpd

[root@cluster1 ~]# cat /etc/httpd2418/httpd.conf  | grep ‘^[^#]’ | grep -vE ‘^[[:space:]]+#’
ServerRoot “/usr/local/apache2418”
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
<IfModule !mpm_prefork_module>
</IfModule>
<IfModule mpm_prefork_module>
</IfModule>
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin you@example.com
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot “/usr/local/apache2418/htdocs”
<Directory “/usr/local/apache2418/htdocs”>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files “.ht*”>
Require all denied
</Files>
ErrorLog “logs/error_log”
LogLevel warn
<IfModule log_config_module>
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined
LogFormat “%h %l %u %t \”%r\” %>s %b” common
<IfModule logio_module>
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %I %O” combinedio
</IfModule>
CustomLog “logs/access_log” common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ “/usr/local/apache2418/cgi-bin/”
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory “/usr/local/apache2418/cgi-bin”>
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/httpd2418/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include /etc/httpd2418/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
[root@cluster1 ~]#

[root@cluster1 ~]#  cat /etc/httpd2418/extra/httpd-vhosts.conf | grep ‘^[^#]’
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot “/usr/local/apache2418/docs/dummy-host.example.com”
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog “logs/dummy-host.example.com-error_log”
CustomLog “logs/dummy-host.example.com-access_log” common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot “/usr/local/apache2418/docs/dummy-host2.example.com”
ServerName dummy-host2.example.com
ErrorLog “logs/dummy-host2.example.com-error_log”
CustomLog “logs/dummy-host2.example.com-access_log” common
</VirtualHost>

How to install redis server on CentOS 7 / RHEL 7

How to install redis server on CentOS 7 / RHEL 7

wget -r –no-parent -A ‘epel-release-*.rpm’ http://dl.fedoraproject.org/pub/epel/7/x86_64/e/
rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm

or

yum install epel-release

install redis server

Now use yum command to install redis server

yum install redis

Two important redis server configuration file’s path
1. /etc/redis.conf
2. /etc/redis-sentinel.conf

To start redis server

systemctl start redis.service
To stop redis server

systemctl stop redis.service
To restart redis server

systemctl restart redis.service
To get running status of redis server

systemctl status redis.service
To enable redis server at system’s booting time.

systemctl enable redis.service
To disable redis server at system’s booting time.

systemctl disable redis.service

check its active

systemctl is-active redis.service

[root@clusterserver1 ~]# redis-cli ping
PONG
[root@clusterserver1 ~]#

[root@clusterserver1 ~]# ss -nlp | grep redis
tcp    LISTEN     0      128    127.0.0.1:6379                  *:*                   users:((“redis-server”,pid=10250,fd=4))
[root@clusterserver1 ~]#

 

[root@clusterserver1 ~]# redis-cli
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set mykey somevalue
OK
127.0.0.1:6379> get mykey
“somevalue”

127.0.0.1:6379> set aaa 111
OK
127.0.0.1:6379> get aaa
“111”
127.0.0.1:6379> quit

Find What Programs, Services, Daemons, Applications Are Using SWAP Memory In Linux

for file in /proc/*/status ; do awk ‘/VmSwap|Name/{printf $2 ” ” $3}END{ print “”}’ $file; done | sort -k 2 -n -r | less

how to find out which processes are swapping in linux

Have you ever logged in to a server, ran free, seen that a bit of swap is used and wondered what’s in there? It’s usually not very indicative of anything, or even overly helpful knowing what’s in there, mostly it’s a curiosity thing.

Either way, starting from kernel 2.6.16, we can find out using smaps which can be found in the proc filesystem. I’ve written a simple bash script which prints out all running processes and their swap usage. It’s quick and dirty, but does the job and can easily be modified to work on any info exposed in /proc/$PID/smaps If I find the time and inspiration, I might tidy it up and extend it a bit to cover some more alternatives. The output is in kilobytes.

#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep “^/proc/[0-9]”` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm –no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk ‘{ print $2 }’`
do
let SUM=$SUM+$SWAP
done
echo “PID=$PID – Swap used: $SUM – ($PROGNAME )”
let OVERALL=$OVERALL+$SUM
SUM=0
done
echo “Overall swap used: $OVERALL”

This will need to be ran as root for it to be able to gather accurate numbers. It will still work even if you don’t, but it will report 0 for any processes not owned by your user. Needless to say, it’s Linux only. The output is ordered alphabetically according to your locale (which admittedly isn’t a great thing since we’re dealing with numbers), but you can easily apply your standard shell magic to the output. For instance, to find the process with most swap used, just run the script like so:

$ ./getswap.sh | sort -n -k 5
Don’t want to see stuff that’s not using swap at all?

$ ./getswap.sh | egrep -v “Swap used: 0” |sort -n -k 5

 

 

#!/bin/bash

    # find-out-what-is-using-your-swap.sh
    # -- Get current swap usage for all running processes
    # --
    # -- rev.0.3, 2012-09-03, Jan Smid          - alignment and intendation, sorting
    # -- rev.0.2, 2012-08-09, Mikko Rantalainen - pipe the output to "sort -nk3" to get sorted output
    # -- rev.0.1, 2011-05-27, Erik Ljungstrom   - initial version


SCRIPT_NAME=`basename $0`;
SORT="kb";                 # {pid|kB|name} as first parameter, [default: kb]
[ "$1" != "" ] && { SORT="$1"; }

[ ! -x `which mktemp` ] && { echo "ERROR: mktemp is not available!"; exit; }
MKTEMP=`which mktemp`;
TMP=`${MKTEMP} -d`;
[ ! -d "${TMP}" ] && { echo "ERROR: unable to create temp dir!"; exit; }

>${TMP}/${SCRIPT_NAME}.pid;
>${TMP}/${SCRIPT_NAME}.kb;
>${TMP}/${SCRIPT_NAME}.name;

SUM=0;
OVERALL=0;
    echo "${OVERALL}" > ${TMP}/${SCRIPT_NAME}.overal;

for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"`;
do
    PID=`echo $DIR | cut -d / -f 3`
    PROGNAME=`ps -p $PID -o comm --no-headers`

    for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
    do
        let SUM=$SUM+$SWAP
    done

    if (( $SUM > 0 ));
    then
        echo -n ".";
        echo -e "${PID}\t${SUM}\t${PROGNAME}" >> ${TMP}/${SCRIPT_NAME}.pid;
        echo -e "${SUM}\t${PID}\t${PROGNAME}" >> ${TMP}/${SCRIPT_NAME}.kb;
        echo -e "${PROGNAME}\t${SUM}\t${PID}" >> ${TMP}/${SCRIPT_NAME}.name;
    fi
    let OVERALL=$OVERALL+$SUM
    SUM=0
done
echo "${OVERALL}" > ${TMP}/${SCRIPT_NAME}.overal;
echo;
echo "Overall swap used: ${OVERALL} kB";
echo "========================================";
case "${SORT}" in
    name )
        echo -e "name\tkB\tpid";
        echo "========================================";
        cat ${TMP}/${SCRIPT_NAME}.name|sort -r;
        ;;

    kb )
        echo -e "kB\tpid\tname";
        echo "========================================";
        cat ${TMP}/${SCRIPT_NAME}.kb|sort -rh;
        ;;

    pid | * )
        echo -e "pid\tkB\tname";
        echo "========================================";
        cat ${TMP}/${SCRIPT_NAME}.pid|sort -rh;
        ;;
esac
rm -fR "${TMP}/";


#!/bin/bash
grep VmSwap /proc/[0-9]*/status | awk -F':' -v sort=$1 '
  {
    split($1,pid,"/") # Split first field on /
    split($3,swp," ") # Split third fireld on space
    cmdlinefile = "/proc/"pid[3]"/cmdline" # Build the cmdline filepath
    getline pname[pid[3]] < cmdlinefile # Get the command line from pid
    swap[pid[3]] = sprintf("%6i %s",swp[1],swp[2]) # Store the swap used (with unit to avoid rebuilding at print)
    sum+=swp[1] # Sum the swap
  }
  END {
    OFS="\t" # Change the output separator to tabulation
    print "Pid","Swap used","Command line" # Print header
    if(sort) {
      getline max_pid < "/proc/sys/kernel/pid_max"
      for(p=1;p<=max_pid;p++) {
        if(pname[p]) print p,swap[p],pname[p] # print the values
      }
    } else {
      for(p in pname) { # Loop over all pids found
        print p,swap[p],pname[p] # print the values
      }
    }
    print "Total swap used:",sum # print the sum
  }'

 

 

Freeipa Centos 6.7

FreeIPA is a solution for managing users, groups, hosts, services, and much, much more. It uses open source solutions with some Python glue to make things work. Identity Management made easy for the Linux administrator.
FreeIPA is an open source alternative to Microsoft Directory Server. It provides the following functionality:

Centralised LDAP based authorisation
Kerberos
Time server
DNS
Certificate Authority
Host and Role based access control

and more, all with a reasonable web GUI and excellent command line tools.

Inside FreeIPA are some common pieces; The Apache Web Server, BIND, 389DS, and MIT Kerberos.

Additionally, Dogtag is used for certificate management, and sssd for client side configurations.

It uses open source solutions with some Python glue to make things work. Identity Management made easy for the Linux administrator.

ipa-components-590x444
Domain:                             rmohan.com
Realm:                              rmohan.COM
Server1:                            cluster1.rmohan.com  (IPA SERVER -1)
Server2(replica):                   cluster3.rmohan.com  (IPA SERVER -2)
Client:                             cluster2.rmohan.com

vi /etc/hosts

192.168.1.60 cluster1.rmohan.com cluster1
192.168.1.62 cluster2.rmohan.com cluster2
192.168.1.63 cluster3.rmohan.com cluster3

Install FreeIPA.
[root@cluster1 ~]# yum -y install ipa-server bind bind-dyndb-ldap

[root@cluster1 ~]# ipa-server-install –setup-dns

The log file for this installation can be found in /var/log/ipaserver-install.log
==============================================================================
This program will set up the IPA Server.

This includes:
* Configure a stand-alone CA (dogtag) for certificate management
* Configure the Network Time Daemon (ntpd)
* Create and configure an instance of Directory Server
* Create and configure a Kerberos Key Distribution Center (KDC)
* Configure Apache (httpd)
* Configure DNS (bind)

To accept the default shown in brackets, press the Enter key.

Existing BIND configuration detected, overwrite? [no]: yes
Enter the fully qualified domain name of the computer
on which you’re setting up server software. Using the form
<hostname>.<domainname>
Example: master.example.com.

Server host name [cluster1.rmohan.com]:

Warning: skipping DNS resolution of host cluster1.rmohan.com
The domain name has been determined based on the host name.

Please confirm the domain name [rmohan.com]:

The kerberos protocol requires a Realm name to be defined.
This is typically the domain name converted to uppercase.

Please provide a realm name [RMOHAN.COM]:
Certain directory server operations require an administrative user.
This user is referred to as the Directory Manager and has full access
to the Directory for system management tasks and will be added to the
instance of directory server created for IPA.
The password must be at least 8 characters long.

Directory Manager password:
Password (confirm):

The IPA server requires an administrative user, named ‘admin’.
This user is a regular system account used for IPA server administration.

IPA admin password:
Password (confirm):

Do you want to configure DNS forwarders? [yes]: yes
Enter the IP address of DNS forwarder to use, or press Enter to finish.
Enter IP address for a DNS forwarder: 192.168.1.63
DNS forwarder 192.168.1.63 added
Enter IP address for a DNS forwarder: 192.168.1.63
DNS forwarder 192.168.1.63 added
Enter IP address for a DNS forwarder:
Do you want to configure the reverse zone? [yes]: yes
Please specify the reverse zone name [1.168.192.in-addr.arpa.]:
Using reverse zone 1.168.192.in-addr.arpa.

The IPA Master Server will be configured with:
Hostname:      cluster1.rmohan.com
IP address:    192.168.1.60
Domain name:   rmohan.com
Realm name:    RMOHAN.COM

BIND DNS server will be configured to serve IPA domain with:
Forwarders:    192.168.1.63, 192.168.1.63
Reverse zone:  1.168.192.in-addr.arpa.

Continue to configure the system with these values? [no]: yes

The following operations may take some minutes to complete.
Please wait until the prompt is returned.

Configuring NTP daemon (ntpd)
[1/4]: stopping ntpd
[2/4]: writing configuration
[3/4]: configuring ntpd to start on boot
[4/4]: starting ntpd
Done configuring NTP daemon (ntpd).
Configuring directory server for the CA (pkids): Estimated time 30 minutes 30 seconds
[1/3]: creating directory server user
[2/3]: creating directory server instance
[3/3]: restarting directory server
Done configuring directory server for the CA (pkids).
Configuring certificate server (pki-cad): Estimated time 33 minutes 30 seconds
[1/21]: creating certificate server user
[2/21]: creating pki-ca instance
[3/21]: configuring certificate server instance
[4/21]: disabling nonces
[5/21]: creating CA agent PKCS#12 file in /root
[6/21]: creating RA agent certificate database
[7/21]: importing CA chain to RA certificate database
[8/21]: fixing RA database permissions
[9/21]: setting up signing cert profile
[10/21]: set up CRL publishing
[11/21]: set certificate subject base
[12/21]: enabling Subject Key Identifier
[13/21]: setting audit signing renewal to 2 years
[14/21]: configuring certificate server to start on boot
[15/21]: restarting certificate server
[16/21]: requesting RA certificate from CA
[17/21]: issuing RA agent certificate
[18/21]: adding RA agent as a trusted user
[19/21]: configure certificate renewals
[20/21]: configure Server-Cert certificate renewal
[21/21]: Configure HTTP to proxy connections
Done configuring certificate server (pki-cad).
Configuring directory server (dirsrv): Estimated time 31 minutes
[1/38]: creating directory server user
[2/38]: creating directory server instance
[3/38]: adding default schema
[4/38]: enabling memberof plugin
[5/38]: enabling winsync plugin
[6/38]: configuring replication version plugin
[7/38]: enabling IPA enrollment plugin
[8/38]: enabling ldapi
[9/38]: disabling betxn plugins
[10/38]: configuring uniqueness plugin
[11/38]: configuring uuid plugin
[12/38]: configuring modrdn plugin
[13/38]: enabling entryUSN plugin
[14/38]: configuring lockout plugin
[15/38]: creating indices
[16/38]: enabling referential integrity plugin
[17/38]: configuring ssl for ds instance
[18/38]: configuring certmap.conf
[19/38]: configure autobind for root
[20/38]: configure new location for managed entries
[21/38]: restarting directory server
[22/38]: adding default layout
[23/38]: adding delegation layout
[24/38]: adding replication acis
[25/38]: creating container for managed entries
[26/38]: configuring user private groups
[27/38]: configuring netgroups from hostgroups
[28/38]: creating default Sudo bind user
[29/38]: creating default Auto Member layout
[30/38]: adding range check plugin
[31/38]: creating default HBAC rule allow_all
[32/38]: Upload CA cert to the directory
[33/38]: initializing group membership
[34/38]: adding master entry
[35/38]: configuring Posix uid/gid generation
[36/38]: enabling compatibility plugin
[37/38]: tuning directory server
[38/38]: configuring directory to start on boot
Done configuring directory server (dirsrv).
Configuring Kerberos KDC (krb5kdc): Estimated time 30 minutes 30 seconds
[1/10]: adding sasl mappings to the directory
[2/10]: adding kerberos container to the directory
[3/10]: configuring KDC
[4/10]: initialize kerberos container
[5/10]: adding default ACIs
[6/10]: creating a keytab for the directory
[7/10]: creating a keytab for the machine
[8/10]: adding the password extension to the directory
[9/10]: starting the KDC
[10/10]: configuring KDC to start on boot
Done configuring Kerberos KDC (krb5kdc).
Configuring kadmin
[1/2]: starting kadmin
[2/2]: configuring kadmin to start on boot
Done configuring kadmin.
Configuring ipa_memcached
[1/2]: starting ipa_memcached
[2/2]: configuring ipa_memcached to start on boot
Done configuring ipa_memcached.
Configuring the web interface (httpd): Estimated time 31 minutes
[1/14]: setting mod_nss port to 443
[2/14]: setting mod_nss protocol list to TLSv1.0 – TLSv1.2
[3/14]: setting mod_nss password file
[4/14]: enabling mod_nss renegotiate
[5/14]: adding URL rewriting rules
[6/14]: configuring httpd
[7/14]: setting up ssl
[8/14]: setting up browser autoconfig
[9/14]: publish CA cert
[10/14]: creating a keytab for httpd
[11/14]: clean up any existing httpd ccache
[12/14]: configuring SELinux for httpd
[13/14]: restarting httpd
[14/14]: configuring httpd to start on boot
Done configuring the web interface (httpd).
Applying LDAP updates
Restarting the directory server
Restarting the KDC
Configuring DNS (named)
[1/9]: adding DNS container
[2/9]: setting up our zone
[3/9]: setting up reverse zone
[4/9]: setting up our own record
[5/9]: setting up kerberos principal
[6/9]: setting up named.conf
[7/9]: restarting named
[8/9]: configuring named to start on boot
[9/9]: changing resolv.conf to point to ourselves
Done configuring DNS (named).

Global DNS configuration in LDAP server is empty
You can use ‘dnsconfig-mod’ command to set global DNS options that
would override settings in local named.conf files

Restarting the web server
==============================================================================
Setup complete

Next steps:
1. You must make sure these network ports are open:
TCP Ports:
* 80, 443: HTTP/HTTPS
* 389, 636: LDAP/LDAPS
* 88, 464: kerberos
* 53: bind
UDP Ports:
* 88, 464: kerberos
* 53: bind
* 123: ntp

2. You can now obtain a kerberos ticket using the command: ‘kinit admin’
This ticket will allow you to use the IPA tools (e.g., ipa user-add)
and the web user interface.

Be sure to back up the CA certificate stored in /root/cacert.p12
This file is required to create replicas. The password for this
file is the Directory Manager password
[root@cluster1 ~]# kinit admin
Password for admin@RMOHAN.COM:
[root@cluster1 ~]#
[root@cluster1 ~]# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: admin@RMOHAN.COM

Valid starting     Expires            Service principal
01/07/16 10:51:49  01/08/16 10:51:46  krbtgt/RMOHAN.COM@RMOHAN.COM
[root@cluster1 ~]#

[root@cluster1 ~]# ipa config-mod –defaultshell=/bin/bash
Maximum username length: 32
Home directory base: /home
Default shell: /bin/bash
Default users group: ipausers
Default e-mail domain: rmohan.com
Search time limit: 2
Search size limit: 100
User search fields: uid,givenname,sn,telephonenumber,ou,title
Group search fields: cn,description
Enable migration mode: FALSE
Certificate Subject base: O=RMOHAN.COM
Password Expiration Notification (days): 4
Password plugin features: AllowNThash
SELinux user map order: guest_u:s0$xguest_u:s0$user_u:s0$staff_u:s0-s0:c0.c1023$unconfined_u:s0-s0:c0.c1023
Default SELinux user: unconfined_u:s0-s0:c0.c1023
Default PAC types: MS-PAC
[root@cluster1 ~]#

Add User Accounts on FreeIPA Server.

ipa user-add mohan –first=Mohan –last=Ramadoss –password

ipa user-add test –first=test –last=test –password

ipa user-add test1 –first=test1 –last=test1 –password

[root@cluster1 ~]# ipa user-add mohan –first=Mohan –last=Ramadoss –password
Password:
Enter Password again to verify:
——————
Added user “mohan”
——————
User login: mohan
First name: Mohan
Last name: Ramadoss
Full name: Mohan Ramadoss
Display name: Mohan Ramadoss
Initials: MR
Home directory: /home/mohan
GECOS field: Mohan Ramadoss
Login shell: /bin/bash
Kerberos principal: mohan@RMOHAN.COM
Email address: mohan@rmohan.com
UID: 1620400001
GID: 1620400001
Password: True
Kerberos keys available: True
[root@cluster1 ~]#

[root@cluster1 ~]# ipa user-add test –first=test –last=test –password
Password:
Enter Password again to verify:
—————–
Added user “test”
—————–
User login: test
First name: test
Last name: test
Full name: test test
Display name: test test
Initials: tt
Home directory: /home/test
GECOS field: test test
Login shell: /bin/bash
Kerberos principal: test@RMOHAN.COM
Email address: test@rmohan.com
UID: 1620400003
GID: 1620400003
Password: True
Kerberos keys available: True
[root@cluster1 ~]#

Configure FreeIPA Client to connect to FreeIPA Server.

Add the record to master node

[root@cluster1 ~]#  ipa dnsrecord-add rmohan.com cluster02 –a-rec 192.168.1.62
Record name: cluster02
A record: 192.168.1.62
[root@cluster1 ~]#

Install Client tools on FreeIPA Client Host and change DNS settings.
[root@cluster2 ~]# yum -y install ipa-client
[root@cluster2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# change to FreeIPA server
[root@cluster2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=9a1e932e-195a-4a19-8474-998c2d9517d0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=00:0C:29:EA:7C:5B
IPADDR=192.168.1.62
PREFIX=24
GATEWAY=192.168.1.254
DNS1=192.168.1.60
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″

DNS1=192.168.1.60
Restart the network

[root@cluster2 ~]# /etc/rc.d/init.d/network restart

[root@cluster2 ~]# ipa-client-install
Discovery was successful!
Hostname: cluster2.rmohan.com
Realm: RMOHAN.COM
DNS Domain: rmohan.com
IPA Server: cluster1.rmohan.com
BaseDN: dc=rmohan,dc=com

Continue to configure the system with these values? [no]: yes
User authorized to enroll computers: admin
Synchronizing time with KDC…
Password for admin@RMOHAN.COM:
Successfully retrieved CA cert
Subject:     CN=Certificate Authority,O=RMOHAN.COM
Issuer:      CN=Certificate Authority,O=RMOHAN.COM
Valid From:  Thu Jan 07 02:43:14 2016 UTC
Valid Until: Mon Jan 07 02:43:14 2036 UTC

Enrolled in IPA realm RMOHAN.COM
Attempting to get host TGT…
Created /etc/ipa/default.conf
New SSSD config will be created
Configured sudoers in /etc/nsswitch.conf
Configured /etc/sssd/sssd.conf
Configured /etc/krb5.conf for IPA realm RMOHAN.COM
trying https://cluster1.rmohan.com/ipa/xml
Forwarding ‘env’ to server u’https://cluster1.rmohan.com/ipa/xml’
Hostname (cluster2.rmohan.com) not found in DNS
DNS server record set to: cluster2.rmohan.com -> 192.168.1.62
Adding SSH public key from /etc/ssh/ssh_host_rsa_key.pub
Adding SSH public key from /etc/ssh/ssh_host_dsa_key.pub
Forwarding ‘host_mod’ to server u’https://cluster1.rmohan.com/ipa/xml’
SSSD enabled
Configuring rmohan.com as NIS domain
Configured /etc/openldap/ldap.conf
NTP enabled
/etc/ssh/ssh_config not found, skipping configuration
Configured /etc/ssh/sshd_config
Client configuration complete.
[root@cluster2 ~]#

[root@cluster2 ~]#  authconfig –enablemkhomedir –update
Starting oddjobd:                                          [  OK  ]
[root@cluster2 ~]# logout

[MohanSystem.Mohanserver] ? ssh mohan@192.168.1.62
X11 forwarding request failed on channel 0
Password expired. Change your password now.
Last login: Thu Jan  7 11:03:19 2016 from 192.168.1.2
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user mohan.
Current Password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Connection to 192.168.1.62 closed.

how disable the user

[root@cluster1 ~]#  ipa user-disable mohan
—————————–
Disabled user account “mohan”
—————————–
[root@cluster1 ~]#

Enable the user id

—————————–
[root@cluster1 ~]# ipa user-enable mohan
—————————-
Enabled user account “mohan”
—————————-

Find the user

[root@cluster1 ~]# ipa user-find mohan
————–
1 user matched
————–
User login: mohan
First name: Mohan
Last name: Ramadoss
Home directory: /home/mohan
Login shell: /bin/bash
Email address: mohan@rmohan.com
UID: 1620400001
GID: 1620400001
Account disabled: False
Password: True
Kerberos keys available: True
—————————-
Number of entries returned 1
—————————-

[root@cluster1 ~]# ipa group-add –desc=’Production Support Group’ prodsupport
————————-
Added group “prodsupport”
————————-
Group name: prodsupport
Description: Production Support Group
GID: 1620400004
[root@cluster1 ~]# ipa group-add-member –users=test,test1 prodsupport
[root@cluster1 ~]# ipa group-add-member –users=test,test1 prodsupport
Group name: prodsupport
Description: Production Support Group
GID: 1620400004
Member users: test, test1
————————-
Number of members added 2
————————-

————————-
[root@cluster1 ~]# ipa group-find prodsupport
—————
1 group matched
—————
Group name: prodsupport
Description: Production Support Group
GID: 1620400004
Member users: test, test1
—————————-
Number of entries returned 1
—————————-
[root@cluster1 ~]# ipa group-del prodsupport

FreeIPA Replication

[root@cluster3 ~]# yum -y install ipa-server bind bind-dyndb-ldap
[root@cluster3 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# change to FreeIPA server
DNS1=192.168.1.60
[root@cluster3 ~]# /etc/rc.d/init.d/network restart

Add DNS entry for Replica Host on FreeIPA server.
# ipa dnsrecord-add [domain name] [record name] [record type] [record]

[root@cluster1 ~]# ipa dnsrecord-add rmohan.com cluster3 –a-rec 192.168.1.63
Record name: cluster3
A record: 192.168.1.63
[root@cluster1 ~]# ipa-replica-prepare cluster3.rmohan.com –ip-address 192.168.1.63
Directory Manager (existing master) password:

Preparing replica for cluster3.rmohan.com from cluster1.rmohan.com
Creating SSL certificate for the Directory Server
Creating SSL certificate for the dogtag Directory Server
Creating SSL certificate for the Web Server
Exporting RA certificate
Copying additional files
Finalizing configuration
Packaging replica information into /var/lib/ipa/replica-info-cluster3.rmohan.com.gpg
Adding DNS records for cluster3.rmohan.com
Using reverse zone 1.168.192.in-addr.arpa.
[root@cluster1 ~]#

[root@cluster1 ~]# scp /var/lib/ipa/replica-info-cluster3.rmohan.com.gpg root@cluster3.rmohan.com:/var/lib/ipa/
The authenticity of host ‘cluster3.rmohan.com (<no hostip for proxy command>)’ can’t be established.
RSA key fingerprint is 60:83:98:1f:db:c6:d4:65:63:f1:21:dc:23:ea:de:97.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘cluster3.rmohan.com’ (RSA) to the list of known hosts.
root@cluster3.rmohan.com’s password:
replica-info-cluster3.rmohan.com.gpg                                                                                                                           100%   35KB  35.1KB/s   00:00
[root@cluster1 ~]#

Setup as a Replica Server on FreeIPA Replica.
The following example set “–no-forwarders” for DNS, but if you set it, specify like “–forwarder=x.x.x.x”.

[root@cluster3 ~]#  ipa-replica-install –setup-ca –setup-dns –no-forwarders /var/lib/ipa/replica-info-cluster3.rmohan.com.gpg
Directory Manager (existing master) password:

Run connection check to master
Check connection from replica to remote master ‘cluster1.rmohan.com’:
Directory Service: Unsecure port (389): OK
Directory Service: Secure port (636): OK
Kerberos KDC: TCP (88): OK
Kerberos Kpasswd: TCP (464): OK
HTTP Server: Unsecure port (80): OK
HTTP Server: Secure port (443): OK
PKI-CA: Directory Service port (7389): OK

The following list of ports use UDP protocol and would need to be
checked manually:
Kerberos KDC: UDP (88): SKIPPED
Kerberos Kpasswd: UDP (464): SKIPPED

Connection from replica to master is OK.
Start listening on required ports for remote master check
Get credentials to log in to remote master
admin@RMOHAN.COM password:

Execute check on remote master
Check connection from master to remote replica ‘cluster3.rmohan.com’:
Directory Service: Unsecure port (389): OK
Directory Service: Secure port (636): OK
Kerberos KDC: TCP (88): OK
Kerberos KDC: UDP (88): OK
Kerberos Kpasswd: TCP (464): OK
Kerberos Kpasswd: UDP (464): OK
HTTP Server: Unsecure port (80): OK
HTTP Server: Secure port (443): OK
PKI-CA: Directory Service port (7389): OK

Connection from master to replica is OK.

Connection check OK
Configuring NTP daemon (ntpd)
[1/4]: stopping ntpd
[2/4]: writing configuration
[3/4]: configuring ntpd to start on boot
[4/4]: starting ntpd
Done configuring NTP daemon (ntpd).
Configuring directory server for the CA (pkids): Estimated time 30 minutes 30 seconds
[1/3]: creating directory server user
[2/3]: creating directory server instance
[3/3]: restarting directory server
Done configuring directory server for the CA (pkids).
Configuring certificate server (pki-cad): Estimated time 33 minutes 30 seconds
[1/17]: creating certificate server user
[2/17]: creating pki-ca instance
[3/17]: configuring certificate server instance
[4/17]: disabling nonces
[5/17]: creating RA agent certificate database
[6/17]: importing CA chain to RA certificate database
[7/17]: fixing RA database permissions
[8/17]: setting up signing cert profile
[9/17]: set up CRL publishing
[10/17]: set certificate subject base
[11/17]: enabling Subject Key Identifier
[12/17]: setting audit signing renewal to 2 years
[13/17]: configuring certificate server to start on boot
[14/17]: configure certmonger for renewals
[15/17]: configure clone certificate renewals
[16/17]: configure Server-Cert certificate renewal
[17/17]: Configure HTTP to proxy connections
Done configuring certificate server (pki-cad).
Restarting the directory and certificate servers
Configuring directory server (dirsrv): Estimated time 31 minutes
[1/31]: creating directory server user
[2/31]: creating directory server instance
[3/31]: adding default schema
[4/31]: enabling memberof plugin
[5/31]: enabling winsync plugin
[6/31]: configuring replication version plugin
[7/31]: enabling IPA enrollment plugin
[8/31]: enabling ldapi
[9/31]: disabling betxn plugins
[10/31]: configuring uniqueness plugin
[11/31]: configuring uuid plugin
[12/31]: configuring modrdn plugin
[13/31]: enabling entryUSN plugin
[14/31]: configuring lockout plugin
[15/31]: creating indices
[16/31]: enabling referential integrity plugin
[17/31]: configuring ssl for ds instance
[18/31]: configuring certmap.conf
[19/31]: configure autobind for root
[20/31]: configure new location for managed entries
[21/31]: restarting directory server
[22/31]: setting up initial replication
Starting replication, please wait until this has completed.
Update in progress
Update in progress
Update in progress
Update succeeded
[23/31]: adding replication acis
[24/31]: setting Auto Member configuration
[25/31]: enabling S4U2Proxy delegation
[26/31]: initializing group membership
[27/31]: adding master entry
[28/31]: configuring Posix uid/gid generation
[29/31]: enabling compatibility plugin
[30/31]: tuning directory server
[31/31]: configuring directory to start on boot
Done configuring directory server (dirsrv).
Configuring Kerberos KDC (krb5kdc): Estimated time 30 minutes 30 seconds
[1/9]: adding sasl mappings to the directory
[2/9]: writing stash file from DS
[3/9]: configuring KDC
[4/9]: creating a keytab for the directory
[5/9]: creating a keytab for the machine
[6/9]: adding the password extension to the directory
[7/9]: enable GSSAPI for replication
[8/9]: starting the KDC
[9/9]: configuring KDC to start on boot
Done configuring Kerberos KDC (krb5kdc).
Configuring kadmin
[1/2]: starting kadmin
[2/2]: configuring kadmin to start on boot
Done configuring kadmin.
Configuring ipa_memcached
[1/2]: starting ipa_memcached
[2/2]: configuring ipa_memcached to start on boot
Done configuring ipa_memcached.
Configuring the web interface (httpd): Estimated time 31 minutes
[1/13]: setting mod_nss port to 443
[2/13]: setting mod_nss protocol list to TLSv1.0 – TLSv1.2
[3/13]: setting mod_nss password file
[4/13]: enabling mod_nss renegotiate
[5/13]: adding URL rewriting rules
[6/13]: configuring httpd
[7/13]: setting up ssl
[8/13]: publish CA cert
[9/13]: creating a keytab for httpd
[10/13]: clean up any existing httpd ccache
[11/13]: configuring SELinux for httpd
[12/13]: restarting httpd
[13/13]: configuring httpd to start on boot
Done configuring the web interface (httpd).
Applying LDAP updates
Restarting the directory server
Restarting the KDC
Using reverse zone 1.168.192.in-addr.arpa.
Configuring DNS (named)
[1/8]: adding NS record to the zone
[2/8]: setting up reverse zone
[3/8]: setting up our own record
[4/8]: setting up kerberos principal
[5/8]: setting up named.conf
[6/8]: restarting named
[7/8]: configuring named to start on boot
[8/8]: changing resolv.conf to point to ourselves
Done configuring DNS (named).

Global DNS configuration in LDAP server is empty
You can use ‘dnsconfig-mod’ command to set global DNS options that
would override settings in local named.conf files

Restarting the web server
[root@cluster3 ~]#

 

[root@cluster3 ~]# kinit admin
Password for admin@RMOHAN.COM:
[root@cluster3 ~]# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: admin@RMOHAN.COM

Valid starting     Expires            Service principal
01/07/16 11:35:16  01/08/16 11:35:12  krbtgt/RMOHAN.COM@RMOHAN.COM
[root@cluster3 ~]#

[root@cluster3 ~]# ipa user-find
—————
4 users matched
—————
User login: admin
Last name: Administrator
Home directory: /home/admin
Login shell: /bin/bash
UID: 1620400000
GID: 1620400000
Account disabled: False
Password: True
Kerberos keys available: True

User login: mohan
First name: Mohan
Last name: Ramadoss
Home directory: /home/mohan
Login shell: /bin/bash
Email address: mohan@rmohan.com
UID: 1620400001
GID: 1620400001
Account disabled: False
Password: True
Kerberos keys available: True

User login: test
First name: test
Last name: test
Home directory: /home/test
Login shell: /bin/bash
Email address: test@rmohan.com
UID: 1620400003
GID: 1620400003
Account disabled: False
Password: True
Kerberos keys available: True

User login: test1
First name: test1
Last name: test1
Home directory: /home/test1
Login shell: /bin/bash
Email address: test1@rmohan.com
UID: 1620400005
GID: 1620400005
Account disabled: False
Password: True
Kerberos keys available: True
—————————-
Number of entries returned 4
—————————-
[root@cluster3 ~]# ipa group-find
—————-
5 groups matched
—————-
Group name: admins
Description: Account administrators group
GID: 1620400000
Member users: admin

Group name: editors
Description: Limited admins who can edit other users
GID: 1620400002

Group name: ipausers
Description: Default group for all users
Member users: mohan, test, test1

Group name: prodsupport
Description: Production Support Group
GID: 1620400004
Member users: test, test1

Group name: trust admins
Description: Trusts administrators group
Member users: admin
—————————-
Number of entries returned 5
—————————-