NGINX Reverse proxy and dynamic/static combination

Source: Internet
Author: User
: This article mainly introduces NGINX Reverse proxy and dynamic/static combination. For more information about PHP tutorials, see. NGINX Reverse proxy and dynamic/static combination

I. default polling mode

Benefit: each request is distributed to different backend servers one by one in chronological order. if the backend server is down, it can be automatically removed.

Http {

Include mime. types;

Default_type application/octet-stream;

# Tcp_nopush on;

Keepalive_timeout 65;

# Configure the reverse proxy. The two machines configured can be multiple

Upstream test {

Server 192.168.136.139: 80;

Server 192.168.136.136: 80;

}

Server {

# Port number

Listen 80;

# Domain name

Server_name localhost;

# Access configuration

Location /{

Root html;

Index index.html index.htm;

}

# Objects that encounter an error jump

Error_page 500 502 503 x.html;

# Accessed Directory

Location =/50x.html {

Root html;

}

Location ~ \. Php $ {

Proxy_pass http: // test; cannot be followed by/http: // test /.

}

# Configure Dynamic/static combination

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

{

# Access Directory

Root/test/web;

Expires 3d;

}

}

II. weight Round Robin

Specify the round-robin probability. weight is proportional to the access ratio, which is used when the backend server performance is uneven.

For example:

Upstream bakend {

Server 192.168.159.10 weight = 5;

Server 192.168.159.11 weight = 10;

}

III. ip_hash (ip-based hash allocation policy)

Each request is allocated according to the hash result of the access ip address, so that each visitor accesses a backend server at a fixed time, which can solve the session problem.

For example:

Upstream resinserver {

Ip_hash;

Server 192.168.159.10: 8080;

Server 192.168.159.11: 8080;

}

4. fair (third-party) based on service response

Requests are allocated based on the response time of the backend server. requests with short response time are prioritized.

Upstream resinserver {

Server server1;

Server server2;

Fair;

}

The above introduces the NGINX Reverse proxy, dynamic and static combinations, including the content, hope to be helpful to friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.