Home > Backend Development > PHP Tutorial > About nginx configuration and use under tomcat

About nginx configuration and use under tomcat

WBOY
Release: 2016-07-29 09:03:03
Original
1024 people have browsed it

upstream localhost {
server 127.0.0.1:8080; //Configure the tomcat that needs to be accessed
}

#After configuring several tomcats, you need to select the access weight

nginx upstream Currently supports 4 allocation methods

1, polling (default)

Each request is allocated to a different post one by one in chronological order End server, if the backend server down goes down, it can be automatically eliminated.

2, weight
specifies the polling probability, weight is proportional to the access ratio, and is used for uneven backend server performance. For example:
upstream bakend {
server 192.168.0.14 weight=10;
server 192.168.0.15 weight=10;
}

2, ip_hash
Each request is assigned by accessing ip’s hash results, so that each visitor has fixed access to a backend server, which can solve the session question. For example:
upstream bakend {
ip_hash;
server 192.168.0.14:88;
server 192.168.0.15:80;
}

3 , fair (Third Party)Requests are allocated according to the response time of the backend server, and those with short response times are allocated first.
upstream backend {
server server1;
server server2;
fair;
}

4 url_hash (No. Third party)

Access to url results to distribute requests so that each url is directed to the same backend server , backend It is more effective when the server is cached. Example: Add

hash

statement to upstream, server statement cannot be written weight and other parameters , hash_method is using the hash algorithm upstream backend {

server squid1:3128; server squid2:3128;
hash $ request_uri;
hash_method crc32;
}

server { listen 80;
server_name localhost; //upstream consistent

                                                                                                                                   logs/host.access.log main;

location ~* .(jpg|gif|png|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar)$ {
root F:/JAVA/project /Upload/out/artifacts/web_war_exploded/img/; //Image server configuration, root followed by the index path
}


Location / {

root html;

index index.html index.htm; proxy_pass http:// localhost;

       }


The above introduces the configuration and use of nginx under tomcat, 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