Nginx: Redirect Backend Traffic Based Upon Client IP Address

You can redirect backend traffic based upon the client’s IP address in Nginx by using the nginx location block and the proxy_pass directive. Here’s an example: http { server { listen 80; server_name example.com; location / { # Redirect client with IP address 10.0.0.1 to backend server A if ($remote_addr = “10.0.0.1”) { proxy_pass http://backend-server-A; … Read more

Linux / Unix whereis Command Examples

The whereis command is a Linux/Unix utility that is used to locate the binary, source code, and manual page files for a given command or program. The whereis command searches the standard Linux/Unix paths for executables, libraries, and man pages, and it displays the location of the files it finds. Here are some common examples … Read more

CentOS Linux 5/6: Change OpenSSH Port Number

To change the OpenSSH port number on CentOS Linux 5/6, you need to edit the sshd_config file. Here’s how: Open the sshd_config file: sudo nano /etc/ssh/sshd_config Locate the line that starts with Port: Port 22 Change the port number to the desired value (e.g., 2222): Port 2222 Save the changes and close the file. Restart … Read more

CentOS / RHEL: Yum Lock Package Version At a Particular Version

In CentOS/RHEL, you can use the yum versionlock plugin to lock a package version at a particular version. This will prevent the package from being upgraded, even if a newer version is available in the repository. Here’s how you can lock a package version: Install the yum-versionlock plugin: yum install yum-plugin-versionlock Find the package and … Read more

HowTo: Prevent Yum From Upgrading The Kernel On a CentOS / Red Hat Enterprise Linux

To prevent yum from upgrading the Linux kernel on a CentOS/Red Hat Enterprise Linux system, you can use the following method: Create a file in the /etc/yum.conf.d/ directory with a descriptive name, such as kernel-updates.conf. Add the following lines to the file: exclude=kernel* Save the file and close it. This will exclude the kernel packages … Read more

Increase NFS Client Mount Point Security For a Web-Server noexec, nosuid, nodev Options

The noexec, nosuid, and nodev mount options can be used to increase the security of NFS client mount points. These options control the execution of executable files, set-user-id (SUID) files, and device files, respectively. Here is how you can mount an NFS share with these options on a web server: Create a directory to mount … Read more

Linux: Log Suspicious Martian Packets / Un-routable Source Addresses

To log suspicious Martian packets (packets with un-routable source addresses) in Linux, you can modify the kernel’s syslog configuration. Here is an example of how to do it: Edit the /etc/sysctl.conf file and add the following line: net.ipv4.conf.all.log_martians = 1 Save the changes and reload the sysctl configuration: sysctl -p Configure the syslog daemon to … Read more

Ubuntu Copy File Command

In Ubuntu, the cp command is used to copy files and directories. Here’s the basic syntax of the cp command: cp [OPTION]… SOURCE DEST Where SOURCE is the file or directory that you want to copy, and DEST is the destination directory where you want to copy the file to. For example, to copy a … Read more