Posts

How to NGINX Solution for Apache ProxyPassReverse

Image
NGINX Solution for Apache ProxyPassReverse Apache configure <VirtualHost myhost:8888>     ServerName myhost     DocumentRoot /path/to/myapp/public     ProxyPass / http://myapp:8080/     ProxyPassReverse / http://myapp:8080/ </VirtualHost> Nginx Reverse Proxy Configure Nginx not have ProxyPassReverse. Therefore a few missing HTTP header. Solve problem Nginx for Apache ProxyPassReverse as below: server {     listen 80;     server_name  www.huuphan.com;     location /home {     proxy_set_header Host $host;         proxy_pass http://IP_Apache:8888;     }     location /app {     proxy_set_header Host $host;         proxy_set_header X-Forwarded-Host $host:$server_port;         proxy_set_header X-Forwarded-Server $host;         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;         proxy_pass http://IP_TOMCAT:8080;     } }

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

sed command regex example

Image
In this tutorial, To use sed command regex such as: Lines starting from A till B printed, how to print between A line to B line , so on. sed command regex example The content sed_test file as picture below: Lines starting from 10 line till 15 line printed  [huupv@huupv ~]$ sed -n '10,12p' sed_test The output as below:     10    operator:x:11:0:operator:/root:/sbin/nologin     11    games:x:12:100:games:/usr/games:/sbin/nologin     12    ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin How to Lines starting from 10 line till end line printed  [huupv@huupv ~]$ sed -n '10,$p' sed_test  The output as picture below: Conclusion   Thought the article, you can printed line to line of file use sed command. How to Lines starting from A line till end line printed 

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    [email protected]: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.

Bash script Change folder Permissions Recursively

Image
In my post, How to use Bash script Change to folder Permissions Recursively. For example, To change all folder and file under huuphan.com folder. To list tree file and folder under huuphan.com folder [root@huupv huupv]# tree huuphan.com/ huuphan.com/ ├── a │   ├── abc.txt │   └── b │       └── c └── K 4 directories, 1 file To use find command list all file and folder under huuphan.com folder [root@huupv huupv]# find /home/huupv/huuphan.com -type d -exec ls -ld {} + >chown_folder.txt To use cat command read chown_folder.txt file [root@huupv huupv]# cat chown_folder.txt  The content in chown_folder.txt file file as below: drwxrwxr-x. 4 huupv huupv 4096 Mar  9 22:38 /home/huupv/huuphan.com drwxrwxr-x. 3 huupv huupv 4096 Mar  9 22:38 /home/huupv/huuphan.com/a drwxrwxr-x. 3 huupv huupv 4096 Mar  9 22:37 /home/huupv/huuphan.com/a/b drwxrwxr-x. 2 huupv huupv 4096 Mar  9 22:37 /home/huupv/huuphan.com/a/b/c drwxrwxr-x. 2 huupv huupv 4096 Mar  9 22:38 /home

List the contents of tar gz file

tar command is archiving utility. Something, you can retrieve extension .tar.gz or .tar.bz2 file. How to list the contents this without extracting from command line. The syntax tar command as below: tar OPTION File_Name With OPTION : t, --list : List the contents of an archive v : Verbosely list files processed j : Filter archive through bzip2 f : filename  You may reading link as below: Iptables how to How to reset password on centos 7 Bash script example List the contents of .tar.gz file To use tar command for .tar.gz as following: $ tar -tvf links-2.12.tar.gz  The output of links-2.12.tar.gz file as below: -rwxr--r-- 1000/1000      1215 2001-10-05 14:03 links-2.12/mailcap.pl -rwxr-xr-- 1000/1000      4654 2015-06-28 22:13 links-2.12/rebuild -rw-r--r-- 1000/1000       461 2003-05-06 01:10 links-2.12/links_16x16_1.xpm -rw-r--r-- 1000/1000      2410 2003-05-06 01:10 links-2.12/links_32x32.xpm -rw-r--r-- 1000/1000      3847 2005-03-01 00:16 links-2.12/links-48x48.xpm -

List top sender address emails in zimbra

How to List top sender address emails in zimbra from command line. From MTA zimbra I will run command to list 6 sender address email Zimbra . The command as below: $ cat /var/log/zimbra.log | awk -F 'from=<' '{print $2}' | awk -F'>' '{print $1}' | sed '/^$/d' | sort | uniq -c | sort -nk1 -r | sed -n '1,6p' Note: sed '/^$/d' : To delete only blank lines sed -n '1,6p' : To print 1 line to 6 line. awk -F 'from=<' '{print $2}' | awk -F'>' '{print $1}' : To print the email of sender address Conclusion Thought the article, To help you list top sender address emails in zimbra. if you any question then command below