Member-only story

Nginx basics

Kathiravan
Oct 30, 2020

--

Nginx basics

nginx got master and workerprocess

master will be who starting the process

worker user will be in user directive

To see master and worker use ps -ef — forest

to validate conf use nginx -t

Reverse proxy (proxy_bypass) to pass IP of client to backend conf below

server {

listen 80;

server_name example.com;

location /
{

root /var/www/blah/;

index index.html index.htm;

}

}

Reverse Proxy
server {

listen 80;

server name example.com;
location / {

proxy_pass http://ip;

}

}

proxy_set_header X-Real-IP $remote_addr;

Client Side for logging : $http_x_real_ip;

To Take TCPDump use

tcpdump -A -vvvv -s 9999 -i wlp1s0 port 80 > /tmp/headers

LoadBalancing (upstream directive) — two types.

Passive — here request will first send to backend 1 , if it fails it will send to backend2. Here we specify timeout and retry

Active — here server polls backends frequently and don’t send requests to failed backend in first attempt itself. here we specify interval to check

Weightage based to backend

Create Zone to get backend availability which is shared across multiple worker process. Otherwise every worker will have seperate backend availability table

Least Connect Method — less processed backend will get the request

--

--

Kathiravan
Kathiravan

No responses yet