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

Optimize the configuration of nginx collected by yourself

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Server_tokens off; # closed version number

Keepalive_timeout 65 180; # setting timeout is 180 seconds

Client_header_timeout 80; # specify the timeout of the request header

Client_body_timeout 80; # specify the request body timeout

Worker_proces 2

The parameter is set to 2, which is the same as the number of cores of CPU, and the number of running processes is set more. In response to client requests, Nginx will not temporarily start new processes to provide services, reducing the overhead of the system and improving the speed of services.

Number of working processes in work_processes 4

Worker_cpu_affinity 00000001 00000010 00000100 00001000bot # specify cpu for each process

Sendfile on; # turns on efficient file transfer mode.

Gzip on; # enable gzip compressed output

Gzip_buffers 4 64k; # indicates that 4 units of 64kB memory is requested as the compression result stream cache

Gzip_http_version 1.1; # is used to set the http protocol version. The default is 1.1.

Gzip_comp_level 2; # specifies the gzip compression ratio with the lowest compression ratio and the fastest processing speed

Gzip_min_length 1k; # sets the minimum number of bytes of pages allowed to be compressed

Gzip_vary on; # allows the front-end cache server to cache gzip-compressed pages

Worker_connections 102400; # maximum number of connections allowed per worker process.

Accept_mutex on

Multi_accept on; # turns on the ability to accept multiple new network connection requests at the same time.

Use epoll; # uses high-performance epoll event-driven for high processing efficiency.

Hotlink protection

Location. (jpg | gif | swf) ${

Valid_referers none blocked .benet.com benet.com

If ($invalid_referer) {

Rewrite ^ / http://www.benet.com/error.png;

}

}

~ *. (jpg | gif | swf) $: matches case-insensitive files that end with .jpg or .gif or .swf.

Valid_referers: set up trusted websites that can use images normally.

None: when refer is empty in the browser, the image is accessed directly in the browser.

Blocked: cases where refer is not empty in the browser, but the values are removed by the agent or firewall, and these values do not start with http:// or https://.

The following URL or domain name: refer contains the URL of the relevant string.

If statement: if the source domain name of the link is not in the list listed by valid_referers and $invalid_referer is 1, do the following, that is, rewrite or return to the 403 page.

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