Posts

How to Configure Postfix only allow whitelisted Recipient Domain

Image
Introduction Learn how to configure Postfix to only allow emails to be sent to whitelisted recipient domains. This step-by-step guide includes user data for testing and minimizes the risk of sending emails to unwanted recipients. In today's digital world, securing your email server is crucial. One effective method to enhance email security is by configuring Postfix to only allow whitelisted recipient domains. This guide will walk you through the process, providing clear examples and detailed steps to help you set up and test this configuration in your environment. In this tutorial, How to Configure " Postfix only allow whitelisted Recipient Domain ". We test environment with user data. To minimize the risk of sending to unwanted email recipients. Configuring Postfix to Allow Only Whitelisted Recipient Domains Step 1: Modify the main.cf File To begin, you need to modify the Postfix main configuration file ( main.cf ) to specify the recipient restrictions. Open the m

Bash script arguments from a file content:Mastering Shell Scripting

Image
Introduction Learn how to change string content of a file using bash script arguments. This guide provides detailed steps and examples, from default values to custom arguments. Master shell scripting to dynamically update file content efficiently. Bash scripting is a versatile and powerful tool for automating tasks and managing system operations. One common requirement is changing specific string content in a file using arguments passed to a script. This guide will demonstrate how to achieve this with a bash script, covering both default values and custom arguments. By following this tutorial, you will enhance your scripting skills and be able to dynamically update file content efficiently. In this tutorial, how to change string content of file as arguments. I written  Bash script arguments from a file content as below: What is Bash Scripting? Bash scripting involves writing a series of commands in a text file to be executed by the Bash shell . It is widely used for automating repetiti

Bash script argument default value and takes optional input arguments

Image
Introduction Learn how to handle default values for arguments and optional input arguments in Bash scripts. This comprehensive guide covers everything from basic to advanced examples, ensuring you can write efficient and flexible scripts. Bash scripting is a powerful tool for automating tasks and managing systems. One essential aspect of writing efficient Bash scripts is handling arguments and providing default values. This ensures that your scripts can handle various scenarios without requiring mandatory inputs every time. In this article, we will explore how to handle default values for arguments and optional input arguments in Bash scripts, from basic to advanced examples. Understanding Bash Script Arguments What are Bash Script Arguments? Bash script arguments are parameters passed to a script at runtime. These arguments are used to provide input data to the script, making it dynamic and versatile. In Bash, arguments are accessed using the $ symbol followed by their position (e.g.

How to NGINX Solution for Apache ProxyPassReverse

Image
Introduction When managing web servers, it's common to encounter the need to reverse proxy through different web servers. Apache's mod_proxy module offers ProxyPass and ProxyPassReverse directives to handle these tasks. However, NGINX can be used as an alternative to Apache for reverse proxy needs due to its performance and configuration simplicity. This article explores how to use NGINX to achieve similar functionality to Apache's ProxyPassReverse. NGINX Solution for Apache ProxyPassReverse Understanding Apache’s ProxyPassReverse The ProxyPassReverse directive in Apache adjusts the URLs in the HTTP headers sent from a reverse proxy. This is essential for maintaining session consistency when the backend server redirects responses. Apache configure <VirtualHost myhost:8888>     ServerName myhost     DocumentRoot /path/to/myapp/public     ProxyPass / http://myapp:8080/     ProxyPassReverse / http://myapp:8080/ </VirtualHost> Configuring NGINX as a Re

Openssl libssl.so.1.1 not found solve problem

How to solve problem Openssl libssl.so.1.1 not found on your system such as centos, ubuntu. Installing openssl missing depens libssl.so.1.1 not found and libcrypto.so.1.1 not found. Openssl libssl.so.1.1 not found problem as below: [huupv@huupv ~]$ ldd /usr/bin/openssl     linux-vdso.so.1 (0x00007ffe185e6000)     libssl.so.1.1 => => not found     libcrypto.so.1.1 => => not found     libz.so.1 => /lib64/libz.so.1 (0x00007fc3ca6f4000)     libdl.so.2 => /lib64/libdl.so.2 (0x00007fc3ca4f0000)     libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc3ca2d2000)     libc.so.6 => /lib64/libc.so.6 (0x00007fc3c9f1c000)     /lib64/ld-linux-x86-64.so.2 (0x00007fc3cb2a1000) Openssl libssl.so.1.1 not found solve problem sudo ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1 sudo ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1 The result, Openssl libssl.so.1.1 not found solve problem [huupv@huupv ~]$ ldd /usr/bin/openssl     li

Mastering the sed command regex example for Linux

Image
Introduction The sed command in Linux is a powerful stream editor that allows users to filter and transform text in various ways. Whether you're working on system administration tasks or programming scripts, mastering sed can significantly improve your efficiency. In this tutorial, we will explore how to use sed with regex to manipulate lines within a file, focusing on printing lines from one point to another. This guide will help you understand the nuances of sed and its regex capabilities, ensuring you can handle text processing with ease. What is the sed Command? The sed (stream editor) command in Linux is used to perform basic text transformations on an input stream (a file or input from a pipeline). It is commonly used for text substitution, but it also allows you to select and manipulate lines, delete text, and more, using regex (regular expressions). Key Features of sed Text Substitution : Replace occurrences of a pattern with a specific string. Line Selection : Selec

Configure Postfix to use Gmail as a Mail Relay

In this tutorial, I setup and Configure Postfix to use Gmail as a Mail Relay with 587 port. OS : Centos User : root Install postfix yum install postfix mailx cyrus-sasl cyrus-sasl-plain To configure postfix to use Gmail as a Mail Relay vi /etc/postfix/main.cf Add or modify the following as below: #To use smpt gmail with 587 port relayhost = [smtp.gmail.com]:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt smtp_tls_security_level = encrypt # Location of CA certificates smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt To configure Gmail authentication vi /etc/postfix/sasl_passwd Add the line as below: [smtp.gmail.com]:587    username@gmail.com:password Running commands as below: chmod 600 /etc/postfix/sasl_passwd chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db postmap /etc/postfix/sasl_pas

Nginx redirect all http to https

In this tutorial, How to use nginx redirect all http to https. All traffic http redirect to https for your website. How to do it..... For example, nginx.conf file for your website     server {             listen 80;             listen [::]:80;             if ($host = www.huuphan.com) {                return 301 https://$host$request_uri;            }             if ($host = huuphan.com) {               return 301 https://$host$request_uri;             }             server_name www.huuphan.com huuphan.com;             return 444;             #return 301 https://$server_name$request_uri;     }     server {             listen 443 ssl http2;             listen [::]:443 ssl http2;             server_name www.huuphan.com huuphan.com;             access_log off;             error_log /path/to/logs/error.log;             root /path/to/webroot;             index index.php index.html index.htm;             location / {                try_files $uri $uri/ /index.php?$

centos change ssh port

in this tutorial, How to change ssh port another with selinux. The default ssh port 22, when you change port another with rules selinux (SELINUX=enforcing) get error can't change ssh port. Solve problem!( Running command following with root account) File selinux with content SELINUX=enforcing as below: [huupv@huupv ~]$ sudo cat /etc/sysconfig/selinux [sudo] password for huupv: # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: #     enforcing - SELinux security policy is enforced. #     permissive - SELinux prints warnings instead of enforcing. #     disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE= can take one of these three values: #     targeted - Targeted processes are protected, #     minimum - Modification of targeted policy. Only selected processes are protected. #     mls - Multi Level Security protection. SELINUXTYPE=targeted How do it... Step 1 : Open sshd_config file # vi /etc/

Centos 7 managing services with Systemd

Centos 7 managing services with Systemd. -List all the current loaded targets as command below: $ sudo systemctl list-units -t target Each services has 3 states; enabled, disabled and static. - To list enabled services as command below: $ sudo systemctl list-unit-files --type=service | grep enabled - To start/stop/restart services as command below: # systemctl status <servicename> # systemctl stop <servicename> # systemctl start <servicename> # systemctl restart <servicename> - To check running ntp services as comman below: $ sudo systemctl list-units --type service --all | grep ntp - Set the service to start a boot: # systemctl enable <servicename> - Disable service start-up boot # systemctl disable service The update later related command line "Centos 7 managing services with Systemd" in this article.