Nginx minimalist introductory tutorial! (turn)

basic introduction

NginxIt is a high-performance HTTPand reverse proxy webserver, but also provides a service.IMAP/POP3/SMTP

NginxBy Igor Saisuoyefu Russia visited the second site development, the first public version released in on May Day.Rambler.ru0.1.02004104

Nginx It characterized by possession of less memory, high concurrency.

In fact nginxconcurrent ability is definitely in the same type of web server performance is better, generally speaking, if we introduce in the project Nginx, our project architecture might look like this:

 

In this architecture, Nginxthe role of the representatives called load balancing server or reverse proxy server, all requests arrive first Nginxon, and then by Nginxone forwarded to advance according to the configured forwarding rules, client requests sent Tomcatup.

This involves two concepts:

  • Server load balancing

It is carried forward the request to reduce the pressure of a particular server. Many load balancing strategy, there are a lot of layers, for some large sites basically from DNSstart load balancing, load balancing hardware and software it has divided, each representing respectively F5and Nginx(currently Nginxhas been F5acquired), the early years, it can also be used Apacheto do load balancing, but the efficiency is better Nginx, so now the mainstream scheme Nginx.

  • Reverse proxy server:

Another concept is a reverse proxy server, to say the reverse proxy, forward proxy have to say, a look at the following chart:

In this process, Google does not know who actually access its client is only aware of this intermediate server to access it. Therefore, agents here, in fact, is an intermediate server proxy client, this agent is called forward proxy.

So what is a reverse proxy it? I played a bit like a reverse proxy 10086 customer service, a look at the following chart:

In this process, the number 10086 is the equivalent of a proxy, really provide services, is the operator, but for the customers, he does not care in the end which is a service provided by the operator, he only needs to remember this number 10086 on the line.

All requests hit the 10086, the 10086 will then forward the request to a particular operator to handle. Therefore, where 10086 is the equivalent of a proxy, but it is the agent of the operator and not the client, the agency called a reverse proxy.

Nginx advantage

In Java development, Nginx has a very widely used, just give a few:

  1. Nginx server using static resources to do: Java resources can be divided into dynamic and static, dynamic needs after Tomcat resolved to return to the browser, such as JSP pages, Freemarker page, the controller returns JSON data, etc., are counted as dynamic resources, dynamic resource through the Tomcat process, the speed will inevitably decline. For static resources such as images, HTML, JS, CSS and other resources, it can be resolved without going through Tomcat, when the client requests for these resources, between the return resources to the client on the line. At this point, you can set up static resources using Nginx server returned static resources directly to the client.

  2. Use Nginx to do load balancing servers, using either Dubbo or Spirng Cloud, in addition to using their own load balancing strategy outside, can also be done using Nginx server load balancing.

  3. It supports high concurrency, low memory consumption, low cost, simple configuration, stable operation.

Nginx installation

Because basically use Nginx on Linux, so Song Ge here mainly to show CentOS 7 install Nginx:

First download Nginx

wget http://nginx.org/download/nginx-1.17.0.tar.gz

Then extract the downloaded directory, enter decompression directory before compiling the installation, you need to install two dependencies:

yum -y install pcre-devel

yum -y install openssl openssl-devel

Then begin to compile and install:

./configure

make

make install

Once installed, the default installation location:

/usr/local/nginx/sbin/nginx

Into the directory sbindirectory, execute nginxto startNginx 

 

After a successful start Nginx, visit Nginx address directly in the browser:

See above page indicates Nginx been installed successfully.

If you modify the Nginx configuration, you can reload Nginx configuration file with the following command:

./nginx -s reload

to sum up

This article can be considered a simple text Nginx literacy, we hope that after reading a basic understanding of Nginx. This article first said that, there are questions please leave a message discussion.

Guess you like

Origin www.cnblogs.com/tomingto/p/11462675.html