浪人 发表于 2019-1-11 09:10:21

Cacti和Zabbix所需Nginx安装配置(二)

  上接“Cacti和Zabbix所需Nginx安装配置(一)” (http://rolandqu.blog.运维网.com/3477736/945703)
  3. nginx基本配置


[*]userdaemon daemon;
[*]
[*]worker_processes 4;
[*]
[*]error_log/usr/local/nginx/logs/nginx_error.logcrit;
[*]
[*]pid      /usr/local/nginx/logs/nginx.pid;
[*]
[*]#Specifies the value for maximum file descriptors that can be opened by this process.
[*]worker_rlimit_nofile 65535;
[*]
[*]events
[*]{
[*]use epoll;
[*]worker_connections 5120;
[*]}
[*]
[*]http
[*]{
[*]include       mime.types;
[*]default_typeapplication/octet-stream;
[*]
[*]#charsetgb2312;
[*]
[*]server_names_hash_bucket_size 128;
[*]client_header_buffer_size 32k;
[*]large_client_header_buffers 4 32k;
[*]client_max_body_size 8m;
[*]
[*]sendfile on;
[*]tcp_nopush   on;
[*]keepalive_timeout 60;
[*]tcp_nodelay on;
[*]
[*]
[*]log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
[*]                  '$status $body_bytes_sent "$http_referer" '
[*]                  '"$http_user_agent" "$http_x_forwarded_for"';
[*]
[*]
[*]access_log   logs/access.log main;
[*]
[*]fastcgi_connect_timeout 300;
[*]fastcgi_send_timeout 300;
[*]fastcgi_read_timeout 300;
[*]fastcgi_buffer_size 64k;
[*]fastcgi_buffers 4 64k;
[*]fastcgi_busy_buffers_size 128k;
[*]fastcgi_temp_file_write_size 128k;
[*]
[*]gzip on;
[*]gzip_min_length1k;
[*]gzip_buffers   4 16k;
[*]gzip_http_version 1.0;
[*]gzip_comp_level 2;
[*]gzip_types       text/plain application/x-javascript text/css application/xml;
[*]gzip_vary on;
[*]
[*]#limit_zonecrawler$binary_remote_addr10m;
[*]
[*]server
[*]{
[*]    listen       80;
[*]    server_namesample.troodo.net;
[*]    index index.html index.htm index.wml index.shtml index.php;
[*]    root/data/website/sample.troodo.net/htdocs;
[*]
[*]    #auth_basic "input you user name andpassword";
[*]    #auth_basic_user_file /usr/local/nginx/conf/nginx_passwd;
[*]
[*]    #limit_conn   crawler20;
[*]
[*]    access_log/data/website/sample.troodo.net/logs/access.logmain;
[*]
[*]    location ~ ^/NginxStatus/ {
[*]      stub_status on; #Nginx 状态监控配置
[*]      access_log off;
[*]            allow 218.249.23.82;
[*]            allow 211.139.94.254;
[*]            deny all;
[*]   }
[*]
[*]    location ~ .*\.(php|php5)?$
[*]{
[*]      #fastcgi_passunix:/tmp/php-cgi.sock;
[*]      fastcgi_pass127.0.0.1:9000;
[*]      fastcgi_index index.php;
[*]      include fcgi.conf;
[*]    }
[*]
[*]    location ~ ^/(WEB-INF|etc|log|logs|conf)/ {
[*]            deny all;
[*]    }
[*]    location ~ .*\.(inc|log|err|txt|conf*|ht*)$ {
[*]            deny all;
[*]    }
[*]    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
[*]    {
[*]            expires      7d;
[*]    }
[*]    location ~ .*\.(javascript|js|css|flash|media|static)?$
[*]    {
[*]            expires      2h;
[*]    }
[*]
[*]      }
[*]}

  注:通过 /usr/local/nginx/sbin/nginx -t 命令检查nginx配置文件语法是否正确
  4. 由于博文字数限制 nginx启动脚本配置请参看“Cacti和Zabbix所需Nginx安装配置(三)”(http://rolandqu.blog.运维网.com/3477736/945707)



页: [1]
查看完整版本: Cacti和Zabbix所需Nginx安装配置(二)