Posts

Showing posts from May, 2018

Postfix only allow whitelisted Recipient Domain

Image
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. Step 1: Add line into main.cf file as below smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_domains, reject Note: Warring /etc/postfix/recipient_domains, reject , Allow receive email in recipient_domain, and REJECT All domain not in whitelisted domain. Step 2: To create recipient domain is the whitelist file mycompany.com OK mail.huuphan.com OK Note: only two domain mycompany.com and mail.huuphan.com receive mail Step 3: To generate hash file: $ sudo postmap /etc/postfix/recipient_domains Step 4: To restart postfix service $ sudo /etc/init.d/postfix restart Now to try sending an email to a another domain not in whitelist. You will find error something like that as below: NOQUEUE: reject: RCPT from …: 554 5.7.1 <[email protected]&g

Bash script arguments from a file content

Image
In this tutorial, how to change string content of file as arguments. I written  Bash script arguments from a file content as below: Input file How to change NAME and DOMAIN in input file with any arguments in content as below. My name: NAME My Blog: https:// DOMAIN .com Output file with arguments default value My name: Huu My Blog: https://huuphan.com Output file with arguments another vaule  My name: Devops My Blog: https://devopsroles.com My bash script  $ cat arguments_file.sh The content bash script #!/bin/bash argument1=Huu argument2=huuphan INPUT=/home/huupv/scripts/input.txt OUTPUT=/home/huupv/scripts/output.txt RED='\033[0;31m' NC='\033[0m' # No Color if [ $# -eq 2 ];then     argument1=$1     argument2=$2 fi sed -f - "$INPUT" > "$OUTPUT"<<EOF     s/NAME/$argument1/g     s/DOMAIN/$argument2/g EOF Running bash script with default value $ ./arguments_file.sh The output as picture below: To run

Bash script argument default value and takes optional input arguments

Image
In this tutorial, I have written bash script Bash script argument default value and takes optional input arguments. Using $# argument to input parameter  in bash script. To run bash script with argument default ./def_argument_default.sh The display argument default as below: Running bash script with argument   ./def_argument_default.sh argument1 argument2 argument3 The display bash script with argument as below: My bash script argument default value and takes optional input arguments as below: #!/bin/bash ############### # bash script argument default value # running argument default:  #    ./def_argument_default.sh  # Running optional input argument: #    ./def_argument_default.sh argument1 argument2 argument3 # ############### argument1=HUU argument2=PHAN argument3=www.huuphan.com RED='\033[0;31m' NC='\033[0m' # No Color if [ $# -eq 3 ];then     argument1=$1     argument2=$2     argument3=$3 fi echo -e "First Name: $RED \t$

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