https://www.cnblogs.com/gustavo

Gustavo's Blog

人类的赞歌是勇气的赞歌!

Nginx通用优化示例

        user nginx;
	worker_processes auto;
	#worket_cpu_affinity auto;
	
	
	error_log /var/log/nginx/error.log warn;
	pid /run/nginx.pid;
	
	
	#include /usr/share/nginx/modules/*.conf;
	
	
	#文件描述符
	worker_rlimit_nofile 35535;
	
	events {
	        use epoll;
	    worker_connections 10240;
	}
	
	http {
	    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
	                      '$status $body_bytes_sent "$http_referer" '
	                      '"$http_user_agent" "$http_x_forwarded_for"';
	
	    access_log  /var/log/nginx/access.log  main;
	
	    sendfile            on;
	    tcp_nopush          on;
	    tcp_nodelay         on;
	    keepalive_timeout   65;
	    types_hash_max_size 2048;
	
	    include             /etc/nginx/mime.types;
	    default_type        application/octet-stream;
	
	
	    include /etc/nginx/conf.d/*.conf;
	
	    server {
	        listen       80 default_server;
	        listen       [::]:80 default_server;
	        server_name  _;
	        root         /usr/share/nginx/html;
	
	        # Load configuration files for the default server block.
	        include /etc/nginx/default.d/*.conf;
	
	        location / {
	         root /data/.../;
	         index index.html index.htm;
	         error_page 405 =200  $request_uri;
	         }
	
	
	        location /api/ {
	          proxy_pass https://.....;
	
	        }
	
	        error_page 404 /404.html;
	            location = /40x.html {
	        }
	
	        error_page 500 502 503 504 /50x.html;
	            location = /50x.html {
	        }
	    }
	
	}
posted @ 2022-08-20 16:29  BitBean  阅读(25)  评论(0编辑  收藏  举报