proxy
In fact, in life there are many many examples. For example: agent buy train tickets, buy travel tickets, purchasing, derivative, housing black intermediary and so on.
nginx forward proxy
Forward proxy object is: kefuduan
It works like as a springboard (VPN virtual network), simply say when we can not access a website, but I was able to access a proxy server, proxy server access can access this site, then I'm even on this proxy server, telling it to get to this resource when I want to access the resource, the proxy server, then I returned to this resource.
nginx reverse proxy
Reverse proxy objects are: server
It works like a proxy server is the same as the original server, as it can protect and hide the original server resources
Now implements a simple example of reverse proxy
Ready to work:
Three roles: nginx1 192.168.13.79 original server
nginx2 192.168.13.24 cattle reverse proxy server
Customer service application server 192.168.13.56
Configuring reverse proxy services here I used the load balancing upstream keyword
1 worker_processes 1; 2 error_log logs/error.log; 3 pid logs/nginx.pid; 4 events { 5 worker_connections 1024; 6 } 7 http { 8 include mime.types; 9 default_type application/octet-stream; 10 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 11 '$status $body_bytes_sent "$http_referer" ' 12 '"$http_user_agent" "$http_x_forwarded_for"'; 13 access_log logs/access.log main; 14 sendfile on; 15 keepalive_timeout 65; 16 upstream slave_pools{ 17 server 192.168.13.79:80 weight=1; 18 } 19 server { 20 listen 80; 21 server_name localhost; 22 location / { 23 proxy_pass http://slave_pools; 24 root html; 25 index index.html index.htm; 26 } 27 error_page 500 502 503 504 /50x.html; 28 location = /50x.html { 29 root html; 30 } 31 } 32 }
过程:当客服访问反向代理服务器的时候这个时候反向代理服务器转发到原始的服务器,获取到资源然后就返回给反向代理服务器,反向代理服务器就返回给客服
可以查看日志信息
1 tail -f /opt/nginx112/logs/access.log