Nginx reverse proxy and Server Load balancer
I. Introduction
Reverse Proxy(Reverse Proxy) means to use a Proxy server to accept connection requests on the internet, and then forward the requests to the server on the internal network, return the
This article introduces to you about Nginx as a static resource Web service and static resource compression, there is a certain reference value, the need for friends can refer to, I hope to help you.
I. Static resource Web Service
1. Static
Alias Root
Nginx configuration with two specified directories of instructions, Root and alias
location/img/
{alias/var/www/image/
;} #若按照上述配置的话, when accessing the files in the/img/directory, NINGX will automatically go to/var/www/image/
This article mainly introduces about Nginx commonly used official module, has certain reference value, now share to everybody, the need friend can refer to
Nginx Common Official Module
Nginx adopts a modular architecture, and most of Nginx's
: This article mainly introduces nginx core module Instruction 1. if you are interested in the PHP Tutorial, refer to it. Alias root
Nginx configuration has two commands for the specified directory: root and alias.
Make sure the ngx_http_gzip_module module is installed.The basic directives are as follows:1.
Syntax (Syntax):
gzip on | off;
Default (Defaults):
gzip off;
Content (Application scenario):
I. nginx_upload_module backgroundThe nginx upload module Nginx_upload_module can be used to more effectively implement resumable upload of large files, and nginx-upload-progress-module can be installed to display the file upload progress.II. Working
First, Memcache application of a PHP and Memcache1. PHP's Memcache ClientPHP has two memcache clients: PHP memcache and PHP memcached. PHP memcache independent PHP Implementation, is the old client, from our practice has been found to have a number
When to use
Used to set the request resources and the server return time, to ensure that a request to occupy a fixed time, beyond the 504 timeout! This will ensure that a request takes too long.
Second, the main parameters
Use the Nginx server if
: This article mainly introduces the commands commonly used by the nginxlua module. if you are interested in the PHP Tutorial, refer to them. Lua_code_cache
Syntax: lua_code_cache on | off
Default: on
Applicable context: http, server, location,
Nginx Load Balancer 1.Nginx Proxy Service OverviewAgent we are often not unfamiliar, the service we often use such as (Agent rental, agent receipt, etc.)Then in the Internet request, the client can not directly to the server to initiate the request,
In the process of URL optimization, it is unavoidable to involve nginx rewrite rules. So how is the Nginx rewrite configured?Rewrite can be found in 4 places: ngx_http_srv_conf,ngx_http_sif_conf,ngx_http_loc_conf,ngx_http_lif_conf. correspond to
The ngx_http_headers_module module I. Preface ngx_http_headers_module module provides two important instructions Add_header and expires To add the "Expires" and "Cache-control" header fields, add any field fields to the response header.
Nginx's reverse proxy module has a number of configurations, the following are some common configuration examples:
1.proxy_pass
Syntax: Proxy_pass URL
Configuration block: location,if
Explanation: This configuration item reverses the current
SyntaxNginx Rewrite is much easier to understand than Apache. The main instructions include if, rewrite, set, return, and break. rewrite is the most critical command.Rewrite The code is as follows:Copy code Syntax: rewrite regex replacement
Request Forwarding (forward) is the URL that the server accesses the destination address directly, and then reads the contents of the response and sends the content to the browser.
Because this jump process is implemented inside the server,
Use the srcache_nginx module in Nginx to build the cache
In nginx, lua can be embedded, so that nginx can execute lua scripts to handle high concurrency and non-blocking requests. In openresty, you can use nginx to directly build srcache_nginx +
Directory:
The configuration used by Nginx as a Web server.
Network connection-related configurations:
Body:The configuration used by Nginx as a Web server.1. HTTP configuration section:syntax:http {...}default:-Context:mainhttp{}:
1.4.2. Lua sequenceNginx under the LUA processing stage and scope of use:Init_by_lua Httpset_by_lua Server, server if, location, location Ifrewrite_by_lua http, server, location, Location Ifaccess_by_lua http,
Limit_connSyntax: limit_conn zone_name the_sizeScope: http, server, location The code is as follows:Copy code Limit_zone one $ binary_remote_addr 10 m;Server {Location/download /{Limit_conn one 1;} Define a record area called "one" with a total
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.