Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation and parameters of proxy module of nginx

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

When using nginx to configure agents, you are sure to use the http_proxy module. This module is also installed by default when installing nginx. Its function is to forward the request to the appropriate server.

When nginx acts as a reverse proxy, nginx uses HTTP/1.1 protocol to communicate with the client. Use the HTTP/1.0 protocol to communicate with the back end, that is, the server being proxied.

Detailed description of parameters:

Basic parameters

When configuring the reverse proxy, you can complete the function of the reverse proxy as long as you configure this parameter, and the rest of the parameters can be added according to your own actual situation.

Field: proxy_pass URL

It is OK to configure ip address or domain name after proxy_pass. Of course, the proxy server must be able to access the back-end server.

This parameter should be configured in location.

Example:

Proxy_pass http://192.168.8.5:8080/uri

Proxy_pass http://www.test.com/uri

Additional parameters

1 、 proxy_temp_path / tmp/proxy_temp

This parameter is configured in http,server,location

Its main function is to cache large proxy requests in a specified local directory. It is usually set in a temporary directory.

2 、 proxy_buffering on

This parameter is configured in http,server,location

This directive is used to open the response cache to the proxied server.

When this parameter is in the off state, the response content obtained from the proxy server is sent directly to the client that sent the request.

When this parameter is in the on state, the response from the proxy server is saved to the cache, and when the reply cannot be saved in memory, part of it is written to disk.

3 、 proxy_buffer_size 4k

This instruction sets the buffer size, and the response content obtained from the proxy server will be read and placed here first. A small response header is usually located in this part of the response content. If the setting is too small, a 502 error may occur.

4 、 proxy_buffers 256 4k

This instruction is used to set the number and size of buffers in which replies are read from the proxy server. The number can be arbitrary, but the size of a cache is usually 4k or 8k.

5 、 proxy_busy_buffers_size 8k

You can request a larger proxy_buffers buffer when the system is busy. It is generally set to twice the size of proxy_buffers.

6 、 proxy_connect_timeout

This instruction is used to set the timeout for links to the proxy server, which is the timeout for the proxy server to initiate a handshake and wait for a response. Do not set it too small, or a 504 error will be reported.

7 、 proxy_read_timeout 60

This parameter is configured in http,server,location

This directive is used to set the timeout for reading replies from the proxied server.

8 、 proxy_max_temp_file_size 1G

Set the size of temporary files

9 、 proxy_method

Used to allow proxies to other HTTP methods.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report