历史潮流浩浩荡荡,顺之则昌,逆之则亡。——孙中山

Nginx配置参考

无主题 徐承恩 2313℃

好久没有写博客了,长此以往怕是对不住一年千把块钱的阿里云ECS费用,本篇徐叔主要分享一下我是如何优雅的配置Nginx服务器,顺便也推广一下APPNode

APPNode:可视化、简易高效、操作透明、高可扩展的 Linux 服务器集群管理面板。

优雅的配置Nginx:

user              nginx;
worker_processes  1;
error_log         /var/log/nginx/error.log warn;
pid               /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include                        /etc/nginx/mime.types;
    default_type                   application/octet-stream;
    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;
    keepalive_timeout              65s;
    include                        /etc/nginx/conf.d/*.conf;
    server_tokens                  off;
    server_names_hash_max_size     512;
    server_names_hash_bucket_size  128;
    client_header_buffer_size      32k;
    large_client_header_buffers    4 32k;
    gzip                           on;
    gzip_disable                   msie6;
    gzip_min_length                1k;
    gzip_comp_level                5;
    gzip_buffers                   4 16k;
    gzip_http_version              1.1;
    gzip_proxied                   any;
    gzip_vary                      on;
    gzip_types                     text/plain text/css text/xml text/javascript text/x-component application/json application/javascript application/xml application/xhtml+xml application/xml+rss application/rss+xml application/atom+xml application/x-font-ttf application/x-web-app-manifest+json font/opentype image/svg+xml image/x-icon;
    fastcgi_buffer_size            64k;
    fastcgi_buffers                4 64k;
    fastcgi_busy_buffers_size      128k;
    fastcgi_temp_file_write_size   256k;
    client_max_body_size           128m;
}

 

转载请注明:思码老徐 » Nginx配置参考

喜欢 (7)