Nginx完整配置说明
http://blog.csdn.net/marising/article/details/3979493
可以参考如下的完整例子
http://wiki.codemongers.com/NginxFullExample
- #用户 用户组
- user www www;
- #工作进程,根据硬件调整,有人说几核cpu,就配几个,我觉得可以多一点
- worker_processes 5;
- #错误日志
- error_log logs/error.log;
- #pid文件位置
- pid logs/nginx.pid;
- worker_rlimit_nofile 8192;
- events {
- #工作进程的最大连接数量,根据硬件调整,和前面工作进程配合起来用,尽量大,但是别把cpu跑到100%就行
- worker_connections 4096;
- }
- http {
- include conf/mime.types;
- #反向代理配置,可以打开proxy.conf看看
- include /etc/nginx/proxy.conf;
- #fastcgi配置,可以打开fastcgi.conf看看
- include /etc/nginx/fastcgi.conf;
- default_type application/octet-stream;
- #日志的格式
- log_format main '$remote_addr - $remote_user [$time_local] $status '
- '"$request" $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- #访问日志
- access_log logs/access.log main;
- sendfile on;
- tcp_nopush on;
- #根据实际情况调整,如果server很多,就调大一点
- server_names_hash_bucket_size 128; # this seems to be required for some vhosts
- #这个例子是fastcgi的例子,如果用fastcgi就要仔细看
- server { # php/fastcgi
- listen 80;
- #域名,可以有多个
- server_name domain1.com www.domain1.com;
- #访问日志,和上面的级别不一样,应该是下级的覆盖上级的
- access_log logs/domain1.access.log main;
- root html;
- location / {
- index index.html index.htm index.php;
- }
- #所有php后缀的,都通过fastcgi发送到1025端口上
- #上面include的fastcgi.conf在此应该是有作用,如果你不include,那么就把fastcgi.conf的配置项放在这个下面。
- location ~ /.php$ {
- fastcgi_pass 127.0.0.1:1025;
- }
- }
- #这个是反向代理的例子
- server { # simple reverse-proxy
- listen 80;
- server_name domain2.com www.domain2.com;
- access_log logs/domain2.access.log main;
- #静态文件,nginx自己处理
- location ~ ^/(images|javascript|js|css|flash|media|static)/ {
- root /var/www/virtual/big.server.com/htdocs;
- #过期30天,静态文件不怎么更新,过期可以设大一点,如果频繁更新,则可以设置得小一点。
- expires 30d;
- }
- #把请求转发给后台web服务器,反向代理和fastcgi的区别是,反向代理后面是web服务器,fastcgi后台是fasstcgi监听进程,当然,协议也不一样。
- location / {
- proxy_pass http://127.0.0.1:8080;
- }
- }
- #upstream的负载均衡,weight是权重,可以根据机器配置定义权重。据说nginx可以根据后台响应时间调整。后台需要多个web服务器。
- upstream big_server_com {
- server 127.0.0.3:8000 weight=5;
- server 127.0.0.3:8001 weight=5;
- server 192.168.0.1:8000;
- server 192.168.0.1:8001;
- }
- server {
- listen 80;
- server_name big.server.com;
- access_log logs/big.server.access.log main;
- location / {
- proxy_pass http://big_server_com;
- }
- }
- }
上面说的include的几个文件,都没有必要改,用的时候include一下就可以。
fastcgi.conf
- # fastcgi.conf
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param QUERY_STRING $query_string;
- fastcgi_param REQUEST_METHOD $request_method;
- fastcgi_param CONTENT_TYPE $content_type;
- fastcgi_param CONTENT_LENGTH $content_length;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name;
- fastcgi_param REQUEST_URI $request_uri;
- fastcgi_param DOCUMENT_URI $document_uri;
- fastcgi_param DOCUMENT_ROOT $document_root;
- fastcgi_param SERVER_PROTOCOL $server_protocol;
- fastcgi_param GATEWAY_INTERFACE CGI/1.1;
- fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
- fastcgi_param REMOTE_ADDR $remote_addr;
- fastcgi_param REMOTE_PORT $remote_port;
- fastcgi_param SERVER_ADDR $server_addr;
- fastcgi_param SERVER_PORT $server_port;
- fastcgi_param SERVER_NAME $server_name;
- fastcgi_index index.php;
- # PHP only, required if PHP was built with --enable-force-cgi-redirect
- fastcgi_param REDIRECT_STATUS 200;
proxy.conf
- # proxy.conf
- proxy_redirect off;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- client_max_body_size 10m;
- client_body_buffer_size 128k;
- proxy_connect_timeout 90;
- proxy_send_timeout 90;
- proxy_read_timeout 90;
- proxy_buffers 32 4k;
mine.types
- # mime.types
- types {
- text/html html htm shtml;
- text/css css;
- text/xml xml rss;
- image/gif gif;
- image/jpeg jpeg jpg;
- application/x-javascript js;
- text/plain txt;
- text/x-component htc;
- text/mathml mml;
- image/png png;
- image/x-icon ico;
- image/x-jng jng;
- image/vnd.wap.wbmp wbmp;
- application/java-archive jar war ear;
- application/mac-binhex40 hqx;
- application/pdf pdf;
- application/x-cocoa cco;
- application/x-java-archive-diff jardiff;
- application/x-java-jnlp-file jnlp;
- application/x-makeself run;
- application/x-perl pl pm;
- application/x-pilot prc pdb;
- application/x-rar-compressed rar;
- application/x-redhat-package-manager rpm;
- application/x-sea sea;
- application/x-shockwave-flash swf;
- application/x-stuffit sit;
- application/x-tcl tcl tk;
- application/x-x509-ca-cert der pem crt;
- application/x-xpinstall xpi;
- application/zip zip;
- application/octet-stream deb;
- application/octet-stream bin exe dll;
- application/octet-stream dmg;
- application/octet-stream eot;
- application/octet-stream iso img;
- application/octet-stream msi msp msm;
- audio/mpeg mp3;
- audio/x-realaudio ra;
- video/mpeg mpeg mpg;
- video/quicktime mov;
- video/x-flv flv;
- video/x-msvideo avi;
- video/x-ms-wmv wmv;
- video/x-ms-asf asx asf;
- video/x-mng mng;
- }
更多的,每个项的具体含义和配置选择,可以参考如下:
http://wiki.codemongers.com/NginxModules
可以依次从MainModule,Events Module,Http Core Module,Http UpStream Module的顺序看。
关于配置和模块的关系是,装了什么模块,就可以用到什么配置,因此配置是灵活多变的。
Nginx完整配置说明的更多相关文章
- Quartz CronTrigger最完整配置说明
转:http://www.blogjava.net/xmatthew/archive/2009/02/15/253864.html Quartz CronTrigger最完整配置说明 CronTr ...
- nginx.conf的完整配置说明
#用户 用户组 user www www; #工作进程,根据硬件调整,有人说几核cpu,就配几个,我觉得可以多一点 worker_processes 5: #错误日志 error_log logs/e ...
- Nginx完整配置配置样例【官方版】
我们主要参考nginx官方给出的完整配置的样例: https://www.nginx.com/resources/wiki/start/topics/examples/full/# 完整摘录如下: n ...
- centos7 nginx完整支持thinkphp pathinfo模式开启方法
thinkphp运行在linux+nginx,如何开启pathinfo模式,我是完整测试过了,没问题的,在thinkphp配置文件 开启 'URL_MODEL' => 1, 1代 ...
- nginx相关配置说明
基础: nginx配置文件主要分为六个区域:main section.events section.http section.sever section. location section.upstr ...
- nginx 常用配置说明
一.location 配置 1.1 语法规则: location [=|~|~*|^~] /uri/ { … }= 开头表示精确匹配^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可 ...
- nginx的配置说明
#定义Nginx运行的用户和用户组user www www; #nginx进程数,建议设置为等于CPU总核心数.worker_processes 8; #全局错误日志定义类型,[ debug | in ...
- FastDFS与Nginx的配置说明
1.简介 FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储.文件同步.文件访问(文件上传.文件下载)等,解决了大容量存储和负载均衡的问题.特别适合以文件为载 ...
- Nginx 完整安装篇
第一步安装各种编译库如c++编译库等 yum install -y gcc //安装GCC ...安装过程省略 yum install -y gcc-c++ //安装C++库用来编译c++ ...安装 ...
随机推荐
- MidPayinfoVO
package nc.vo.arap.payablebill; import nc.vo.pub.SuperVO; import nc.vo.pub.lang.UFDate; import nc.vo ...
- percent-encode 百分号编码
原文地址:http://www.imkevinyang.com/2009/08/详解javascript中的url编解码.html 摘要 URI(统一资源标识)编解码 为什么需要编码 哪些需要编码 如 ...
- iOS开发——https+证书
由于公司项目的需要,经过调研后,已成功. 同事已把此问题写成博客<[加密解密]HTTPS>,我就直接转用了 附带链接如下: http://www.jianshu.com/p/8351917 ...
- TortoiseSVN本地代码版本控制设置步骤。
1.下载安装TortoiseSVN客户端. 2.在某个盘创建空的文件夹作为项目代码的版本库.在空的文件夹内部右键鼠标TortoiseSVN->Create repository here 3.在 ...
- .Net 程序集 签名工具sn.exe 密钥对SNK文件 最基本的用法
阐述签名工具这个概念之前,我先说说它不是什么: 1.它不是用于给程序集加密的工具,它与阻止Reflector或ILSpy对程序集进行反编译一毛钱关系都没有. 2.它很讨厌人们把它和加密联系在一起. 我 ...
- windows2003可用gt630显卡驱动
http://file2.mydrivers.com/display/301.42-desktop-winxp-32-international-whql.exe 驱动精灵自动下载的不好用,这个版本可 ...
- python拆分excel脚本
因为需要将一个很大的excel按500条拆分为多个excel,手工操作实在太麻烦,就写了个python小脚本,现在是分为了多个sheet页,使用者可根据自己实际情况修改成多个文件的形式 #!/usr/ ...
- [leetcode]352. Data Stream as Disjoint Intervals
数据流合并成区间,每次新来一个数,表示成一个区间,然后在已经保存的区间中进行二分查找,最后结果有3种,插入头部,尾部,中间,插入头部,不管插入哪里,都判断一下左边和右边是否能和当前的数字接起来,我这样 ...
- STL简介
由于不同书籍和翻译问题对STL中的术语可能有差别本文采用侯杰<STL源码剖析>中的术语 STL的组件 包含6个组件,分别为容器.算法.迭代器.仿函数(函数对象).配接器(适配器).配置器( ...
- OpenJudge 2813 画家问题 / Poj 1681 Painter's Problem
1.链接地址: http://bailian.openjudge.cn/practice/2813 http://poj.org/problem?id=1681 2.题目: 总时间限制: 1000ms ...