nginx配置文件nginx.conf
来源:互联网 发布:空气刘海定型喷雾知乎 编辑:程序博客网 时间:2024/05/19 04:56
#定义Nginx运行的用户和用户组user root root;#user nobody;#定义了nginx对外提供web服务时的worker进程数。最优值取决于许多因素,包括(但不限于)CPU核的数量、存储数据的硬盘数量 #及负载模式。不能确定的时候,将其设置为可用的CPU内核数将是一个好的开始(设置为“auto”将尝试自动检测它)。 worker_processes 3;#全局错误日志定义类型,[ debug | info | notice | warn | error | crit ]error_log /usr/local/nginx/logs/error.log;error_log /usr/local/nginx/logs/error.log notice;error_log /usr/local/nginx/logs/error.log info;pid /usr/local/nginx/logs/nginx.pid;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;#工作模式与连接数上限events {#单个进程最大连接数(最大连接数=连接数*进程数) worker_connections 1024;}#设定http服务器,利用它的反向代理功能提供负载均衡支持http { #文件扩展名与文件类型映射表 include mime.types; #默认文件类型 default_type application/octet-stream; #服务器名字的hash表大小 server_names_hash_bucket_size 128; #设定请求缓冲 client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; #设定日志格 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 /usr/local/nginx/logs/access.log main; #设定负载均衡的服务器列表,weight是权重,可以根据机器配置定义权重。 #weigth参数表示权值,权值越高被分配到的几率越大。 upstream server_group1{ server 20.10.81.101:80; } #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on, #如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。 #注意:如果图片显示不正常把这个改成off。 sendfile on; #tcp_nopush on; #长连接超时时间,单位是秒 #keepalive_timeout 0; keepalive_timeout 65; #gzip模块设置 #gzip on; #虚拟主机的配置 server { #监听端口 listen 80;#域名可以有多个,用空格隔开 server_name localhost.localdomain; #charset koi8-r; access_log off; #对请求到/group1/M00路径上的请求处理#这个是根据我自己做Fastdfs分布式文件系统做的配置#这里是对nginx和fastdfs-nginx-module的整合 #FastDFS通过Tracker服务器,将文件放在Storage服务器存储,但是同组之间的服务器需要复制文件,有延迟的问题#假设Tracker服务器将文件上传到了192.168.1.80,文件ID已经返回客户端,这时,后台会将这个文件复制到192.168.1.30,#如果复制没有完成,客户端就用这个ID在192.168.1.30取文件,肯定会出现错误#这个fastdfs-nginx-module可以重定向连接到源服务器取文件,避免客户端由于复制延迟的问题出现错误#下面的这个配置就是使用nginx的扩展模块fastdfs-nginx-module模块location /group1/M00 { root /usr/local/src/fastdfs/storage/data; ngx_fastdfs_module; } # 定义错误提示页面 #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } #PHP 脚本请求转发配置 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}}
0 0
- nginx nginx.conf配置文件
- nginx配置文件nginx.conf
- Nginx配置文件nginx.conf说明
- Nginx配置文件nginx.conf详解
- Nginx 配置文件nginx.conf 详解
- Nginx配置文件nginx.conf 总结
- nginx配置文件nginx.conf解读
- nginx配置文件nginx.conf解读
- 初识nginx配置文件--nginx.conf
- NGINX配置文件nginx.conf详解
- nginx 本地nginx.conf配置文件
- nginx配置文件nginx.conf详解
- Nginx配置文件nginx.conf详解
- nginx配置文件nginx.conf实例
- Nginx的配置文件nginx.conf
- Nginx 配置文件(nginx.conf)
- Nginx配置文件详解(nginx.conf)
- Nginx配置文件nginx.conf详解
- Android Studio导入Project、Module的正确方法
- 内存管理与B树
- C#使用Log4Net记录日志
- Java 懒汉式单例 饿汉式单例
- 堆排序的问题——大顶堆例子
- nginx配置文件nginx.conf
- C++之多态性与虚函数
- Struts 2 @ResultPath annotation example
- [Celery]Run celery as daemon
- epoll详解
- Java反射机制及其获取InputStream的两种方式
- TreeSet保证元素唯一并实现排序的原理
- Android 的权限设置大全
- 背景提取—修改高斯混合模型BackgroundSubtractorMOG2中的参数及使用