Enabling Modules for ReverseProxy

Update package lists:

apt-get update

Install Apache2 with mod_proxy:

sudo apt-get install libapache2-mod-proxy-html

Install libxml2 module:

apt-get install libxml2-dev

On /etc/apache2/apache2.conf add below code

LoadModule  proxy_module         /usr/lib/apache2/modules/mod_proxy.so
LoadModule  proxy_http_module    /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule  headers_module       /usr/lib/apache2/modules/mod_headers.so
LoadModule  deflate_module       /usr/lib/apache2/modules/mod_deflate.so
LoadFile    /usr/lib/x86_64-linux-gnu/libxml2.so

Add a sample reverse proxy configuration to the same file:

ProxyPass /subfolder http://127.0.0.1:9999/
ProxyPassReverse /subfolder http://127.0.0.1:9999/

Restart Apache2:

systemctl restart apache2

Basic netstat Command

netstat [OPTIONS]
    (none)
       Default : Displays  a  list of open sockets

    --route , -r
       Display  the kernel routing tables.

   --groups , -g
       Display multicast group membership information for IPv4 and IPv6.

   --interfaces, -i
       Display a table of all network interfaces.

   --masquerade , -M
       Display a list of masqueraded connections.

   --statistics , -s
       Display summary statistics for each protocol.

Netstat command

netstat

Show numerical addresses

netstat -n

Show only tcp connections

netstat -t

Show only udp connections

netstat -u

Show only listening sockets

netstat -l

Show name and PID of programs

netstat -p

Show network statistics

netstat -s

Show kernel routing table

netstat -r

Show listening ports, process, port numbers

netstat -pln

Show listening ports, process, port numbers for TCP

netstat -plnt

chown and chmod Command basics

Chown

# chown owner-user file 
# chown owner-user:owner-group file

Listing files with owner and group

# ls -la

Changing owner and owner group

# chown praison file.txt
# chown praison:praison file.txt

Change the owner for a folder

# chown praison:praison /folder

Change the owner for all subfiles of the folder

# chown -R praison:praison /folder

Chmod

# chmod options permissions file name

Change permission for a single file

# chmod 644 filename

Change permission for all files under a directory

# chmod -R 755 directory

Make your file executable

# sudo chmod +x filename

Basic PS Linux commands

Display all processes

$ ps ax
$ ps -ef
$ ps aux
$ ps -ef -f

Display process by a user

$ ps -f -u www-data

Display process by process ID or name

$ ps ax | grep apache
$ ps -ef | grep apache
$ ps -C apache2
$ ps -f  -p 3150,7298,6544

Sort process by CPU or memory usage

$ ps aux --sort=-pcpu | head -5

Display elapsed time of a process

$ ps -e -o pid,comm,etime

Realtime process viewer

$ watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15'