nginx, LNMP deployment

nginx features:

(1) web server:

The default web directory is: / usr / share / nginx / html

 

(2) reverse proxy server:

       nginx instead of client access back-end servers, back-end server only know nginx request, and returns the results to the nginx, nginx the results returned to the client

Found nginx configuration file location, configuration section below, the default parameter is empty

location / {
}

Do reverse proxy / virtual path followed by the name, with the following url proxy_pass server module and upstream of, for example:

location /node1 {
        proxy_pass http://192.168.210.131/;
        }

 

(3) Load balancing servers:

        nginx is responsible for forwarding the client's request, polling to get the back-end server is to access the client's request, the server returned to the client directly to configure the location of the results reverse proxy, the client sends a request to a cluster (zn cluster name, you can easily play), then upstream module declaration cluster and write the address of a real back-end server, for example:

    include /etc/nginx/conf.d/*.conf;
    upstream zn {
    server 192.168.210.132 weight=2 max_fails=2 fail_timeout=2;
    server 192.168.210.131 weight=1 max_fails=2 fail_timeout=2;
    }
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
        index        index.php index.html;
        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;

        location / {
        proxy_pass http://zn/;
        }

 

Guess you like

Origin www.cnblogs.com/cloudhere/p/10946522.html