NGINX reverse proxy, dynamic and static combination

WBOY
Release: 2016-08-08 09:24:38
Original
1188 people have browsed it

NGINX reverse proxy, dynamic and static combination

1. Default polling mode

Benefits:Each request is assigned to a different backend server one by one in chronological order. If the backend server goes down , can be automatically eliminated.

http {

include mime.types;

default_type application/octet-stream;

#tcp_nopush on;

keepalive_timeout 65;

#reverse proxy Configuration This is the two machines configured. It can be multiple

upstream test{

server 192.168.136.139:80;

server 192.168.136.136:80 ;

} vServer {

#

Listen 80;

#domain name

server_name localhost;

#access some configuration

location / {

                                                                         

#Encountered an error jump file

                  error_page     500 502 503 504 /50x.html;

#Visited directory

location = /50x.html {

root html;

~ .php $ {r Proxy_pass http:// test; You cannot add/http: // test/is the wrong}}

#Configure dynamic static binding

Location ~.*. (html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$

{

#Visit directory

 root /test/web;

expires   3d;

}

}

2. Weight weight polling

specifies the polling probability, and the weight is proportional to the access ratio, which is used when the back-end server performance is uneven.

For example:

upstream bakend {

server 192.168.159.10 weight=5;

server 192.1 68.159.11 weight=10;

}

3. ip_hash (ip-based hash allocation strategy)

Each request is allocated according to the hash result of the accessed IP, so that each visitor has fixed access to a back-end server, which can solve the session problem.

For example:

upstream resinerver{

ip_hash;

server 192.168.159.10:8080;

server 192.168.159.11:8080;

}

4. fair (third party) is based on service responsiveness

and allocates requests according to the response time of the back-end server. Those with short response times are prioritized.

upstream resinerver{

server server1;

server server2;

fair;

}

The above introduces the NGINX reverse proxy and dynamic and static combination, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!