mobile version detect with same url in nginx using proxy_pass :-

Friday, March 30, 2018

Mobile version detect with same url in nginx using proxy_pass :-

if ($http_user_agent ~* "/Mobile|Android|BlackBerry/") {
    proxy_pass    http://m.example.com$request_uri;
}

proxy_pass    http://www.example.com$request_uri;


http {
    upstream app-pc {
        server 127.0.0.1:8001;
    }

    upstream app-mobile {
        server 127.0.0.1:8002;
    }

    server {
        listen       8080;
        server_name  localhost;

        # check user agent
        if ($http_user_agent ~* '(iPhone|iPod|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)') {
          set $ua_type "@mobile";
        }

        location / {
            # root
            if ($ua_type = "@mobile"){
                set $page_cache_path /var/www/app_pc/public;
            }
            if ($ua_type != "@mobile"){
                set $page_cache_path /var/www/app_mobile/public;
            }
            root $page_cache_path;

            # for page cache
            if (-f $request_filename) { 
                break; 
            }
            if (-f $request_filename/index.html) {
                rewrite (.*) $1/index.html break;
            }
            if (-f $request_filename.html) {
                rewrite (.*) $1.html break;
            }

            # proxy
            if ($ua_type = "@mobile"){
                proxy_pass http://app-mobile;
            }
            if ($ua_type != "@mobile"){
                proxy_pass http://app-pc;
            }
        }
    }
}

Read more...

How to connect multiple VPNs using OpenVPN on Windows 7 on the same time

How to connect multiple VPNs using OpenVPN on Windows 7 on the same time :-

you will need to create some additional TAP-WIN32 adapters if you haven't already.

If you are using OpenVPN 2.3.x or later, run addtap.bat:

C:\Program Files\TAP-Windows\bin\addtap.bat
If you are using an older version of OpenVPN, run the tapinstall command

C:\Program Files\OpenVPN\bin\tapinstall.exe
C:\Program Files (x86)\OpenVPN\bin\tapinstall.exe
(NOTE: Maybe you should open the cmd with Administrator Privileges)

The easiest way, not to mention tapinstall.exe, is to run Start > All Programs > OpenVPN > Utilities > Install > Add a new TAP vitrual ethernet adapter

Please remember to run it with administrator privileges, in other case you will just get tapinstall failed.

Read more...

Unable to send an email: 535 5.7.8 Error: authentication failed: authentication failure

Thursday, March 29, 2018

Unable to send an email: 535 5.7.8 Error: authentication failed: authentication failure:-


we can be found this exception in /var/log/maillog :

Dec  4 06:06:34 servername postfix/qmgr[6334]: DA7FB101118C: from=, size=827, nrcpt=1 (queue active)
Dec  3 04:04:22 servername postfix/error[25863]: DA7FB101118C: to=, relay=none, delay=0.1, delays=0.1/0/0/0, dsn=4.7.8, status=deferred (delivery temporarily suspended: SASL authentication failed; server someexternalserver.com [203.0.113.2] said: 535 5.7.8 Error: authentication failed: authentication failure)
relayhost is configured in /etc/postfix/main.cf :

# cat /etc/postfix/main.cf | grep  "relayhost ="
relayhost = someexternalserver.com

Cause
Issues on someexternalserver.com side.

Resolution
Contact owner of someexternalserver.com to check the issue.
2.1. relayhost can be disabled by commenting it in /etc/postfix/main.cf

    # cat /etc/postfix/main.cf | grep  "relayhost ="
    #relayhost = someexternalserver.com
2.2. Restart postfix:

    # service postfix restart

Read more...

How to remove files /bin/rm: Argument list too long

How to remove files /bin/rm: Argument list too long :-

How to remove files /bin/rm: Argument list too long by using below command.

find . -mindepth 1 -iname "*.xls" -print0|xargs --no-run-if-empty --null rm -rf

Read more...

How to Flush or Delete Postfix Mail Queue

How to Flush or Delete Postfix Mail Queue:-

there are following commands to flush/delete postfix mail queue.

1. List All Emails :-
To list all mail of queue, use one of the following commands.
postqueue -p

2. Flush All Emails :-
To delete or flush all emails from Postfix mail queue using the following command.
postsuper -d ALL

3. Flush Deferred Mails Only :-
You can only delete all deferred emails only from mail queue. Use the following command to delete deferred emails from the queue.
postsuper -d ALL deferred

4. Remove Specific Email :-
If you want to remove any specific email. Use the following command to remove specific emails only. First search the ID of that email like below command
postqueue -p | grep "email@example.com"

056CB129FF0*    5513 Sun Feb 26 02:26:27  email@example.com
Now delete the mail from mail queue with id 056CB129FF0.

postsuper -d 056CB129FF0

Read more...

How to Install Apache Solr 5.1 on CentOS 6

How to Install Apache Solr 5.1 on CentOS 6 :-

following are the steps for how to install Apache Solr 5.1 on a CentOS 6 server . 

Step 1. Install Solr :-
download and install solr first.
# cd /opt/solr 
# wget http://mirror.symnds.com/software/Apache/lucene/solr/5.1.0/solr-5.1.0.tgz -O solr-5.1.0.tgz

Uncompress the file:
# tar -xzvf ./solr-5.1.0.tgz
Now the directory /opt/solr/solr-5.1.0 will contain all the Solr files. 

Step 2. Install Java :-
First, check if Java is already installed:
# which java
  If not installed, install the latest version :

# yum list available java* 
# yum install java-1.8.0-openjdk.x86_64

Verify install:
# which java 
[...] 
# java -version 
openjdk version "1.8.0_45" 
OpenJDK Runtime Environment (build 1.8.0_45-b13) 
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

Step 3. Start Solr :-
Next start Solr and test instance:
# cd /opt/solr/solr-5.1.0 
# bin/solr start -noprompt

Verify Solr is running:
# ps aux | grep solr 
[...] 
# lsof -i :8983 
[...]

Step 4. Install NMAP :-
The Solr service can also be verified from a remote machine. First, install nmap if not already installed on remote machine:
# yum install nmap
Then test the Solr service from the remote machine:
# nmap -p 8983 [remote IP address] 

Starting Nmap 5.51 ( http://nmap.org ) at * EDT 
Nmap scan report for 
Host is up (0.054s latency). 
PORT STATE SERVICE 
8983/tcp open unknown 

Nmap done: 1 IP address (1 host up) scanned in 0.25 seconds

If the remote machine is unable to connect try setting up firewall rules, or disable firewall for testing:
# service iptables stop
Stopping Solr can be accomplished using:
# cd /opt/solr/solr-5.1.0 
# bin/solr stop


Step 5. Auto Start Solr :-
Finally, Solr can be setup as a service that starts when the server boots. Create the script file 

/etc/init.d/solr and add:

#!/bin/sh 
# chkconfig: 2345 95 20 
# description: Solr Server 
# Solr Server service start, stop, restart 
# @author Shay Anderson 04.15 

SOLR_DIR="/opt/solr/solr-5.1.0" 

case $1 in 
      start) 
            echo "Starting Solr..." 
            $SOLR_DIR/bin/solr start -noprompt 
            sleep 1 
            lsof -i :8983 
            ;; 
      stop) 
            echo "Stopping Solr..." 
            $SOLR_DIR/bin/solr stop 
            ;; 
      restart) 
            $0 stop 
            sleep 2 
            $0 start 
            ;; 
      status) 
            $SOLR_DIR/bin/solr status 
            ;; 
      *) 
            echo "Usage: $0 [start|stop|restart]" 
            exit 1 
            ;; 
esac 

exit 0

Save the file and set permissions:
# chmod +x /etc/init.d/solr

Now the Solr service can be started/stopped using:
# service solr start 
[...] 
# service solr stop 
[...]

Enable auto start service on server boot:
# cd /etc/init.d 
# chkconfig --add solr 
# chkconfig | grep solr
Now the Solr service will start on server boot. 

Create New Core
A new core can be created using:
# cd /opt/solr/solr-5.1.0 
# bin/solr create -c mycore
This will create the core and core directory /opt/solr/solr-5.1.0/server/solr/mycore

Read more...

How to Show All Running Processes in Linux

How to Show All Running Processes in Linux :-

How to show all running process in Linux operating systems using command line or GUI options.

Linux commands to list processes :-
following commands to display info about processes on Linux:

top command : Display and update sorted information about processes.
atop command : Advanced System & Process Monitor.
htop command : Interactive process viewer.
pgrep command : Look up or signal processes based on name and other attributes.
pstree command : Display a tree of processes.

How to list process with the ps command :-
following ps command to display all running process:
# ps -aux | less

OR
# ps aux | less

Where,

A : Select all processes
u : Select all processes on a terminal, including those of other users
x : Select processes without controlling ttys

How To See every process on the Linux system :-
Either pass -A or -e option to show all processes on your server/workstation powered by Linux:
# ps -A
# ps -e

How to see every process except those running as root :-
To negates the selection pass the -N or --deselect option to the ps command:
# ps -U root -u root -N

OR
# ps -U root -u root --deselect

How to See process run by user xyz :-
Select by process by effective user ID (EUID) or name by passing username such as xyz:
# ps -u xyz

Linux running processes with top command :-
The top program provides a dynamic real-time view of a running system. Type the top at command prompt:
# top


How to display a tree of processes :-
The pstree command shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.
$ pstree

Print a process tree using ps :-
# ps -ejH
# ps axjf

How to Get info about threads using following command :-
Type the following command:
# ps -eLf
# ps axms

How to show Task: Get security info :-
Type the following command:
# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM

How to save process snapshot to a file :-
Type the following command:
# top -b -n1 > /tmp/process.log

Or you can email result to yourself : -
# top -b -n1 | mail -s 'Process snapshot' you@example.com

How to lookup process by name :-
Use pgrep command command. It looks through the currently running processes and lists the process IDs which matches the selection criteria to screen. For example, display firefox process id:
$ pgrep firefox

Sample outputs:

3356

Following command will list the process called sshd which is owned by a user called root:
$ pgrep -u root sshd

Read more...

How to Check Postfix Version

How to Check Postfix Version :-

How to check your postfix mail server version. Basically, postfix is a open-source mail transfer agent (MTA) and an alternative for Sendmail service which provide the same function.

Following Command for check version  :

postconf -d | grep mail_version

Examples :

[root@centos ~]# postconf -d | grep mail_version
mail_version = 2.6.2
milter_macro_v = $mail_name $mail_version

Read more...

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP