Nginx配置文件说明doc下载

时间:18-11-07 来源: 作者: 点击:

beat365下载苹果版Nginx配置文件说明志存高远脚踏实地骆超飞Nginx配置文件说明志存高远脚踏实地骆超飞一、基本配置#运行用户userwwwwww#启动进程workerprocesses#全局错误日志及PID文档errorlogwebwwwlogserrorlognoticepidusrlocalnginxlogsnginxpid#工作模式及连接数上限events{useepollworkerconnections}#设定http服务器利用他的反向代理功能提供365bet最新官网备用网站_365bet盘口编辑器_澳门365bet下载均衡支持http{#设定mime类型includemimetypesdefaulttypeapplicationoctetstream#设定日志格式logformatmain'$remoteaddr$remoteuser$timelocal''"$request"$status$bytessent''"$httpreferer""$httpuseragent"''"$gzipratio"'logformatdownload'$remoteaddr$remoteuser$timelocal''"$request"$status$bytessent''"$httpreferer""$httpuseragent"''"$httprange""$senthttpcontentrange"'#设定请求缓冲clientheaderbuffersizeklargeclientheaderbuffersk#开启gzip模块gzipongzipminlengthgzipbufferskgziptypestextplainoutputbufferskpostponeoutput#设定accesslogaccessloglogsaccesslogmainclientheadertimeoutmclientbodytimeoutmsendtimeoutmsendfileontcpnopushontcpnodelayonkeepalivetimeout#设定服务器支持shtmlssionssisilenterrorsonssitypestextshtml#设定365bet最新官网备用网站_365bet盘口编辑器_澳门365bet下载均衡的服务器列表upstreammysvr{#weigth参数表示权值权值越高被分配到的几率越大#本机上的Squid开启端口server:weight=server:weight=server:weight=}#设定虚拟主机server{listenservernamewwwlnmpcomindexindexhtmlindexhtmindexphprootwebwwwcharsetgb#设定本虚拟主机的访问日志accessloglogswwwlnmpcomaccesslogmain#假如访问img*,js*,css*资源则直接取本地文档不通过squid#假如这些文档较多不推荐这种方式因为通过squid的缓存效果更好location~*(gif|jpg|jpeg|png|bmp|swf)${志存高远脚踏实地骆超飞expiresd}location~*(js|css)${expiresh}#假如这些文档较多不推荐这种方式因为通过squid的缓存效果更好location~*(php|php)${#fastcgipassunix:tmpphpcgisockfastcgipass:fastcgiindexindexphpincludefcgiconf}#设置主机开启SSI支持shtmllocation~*(shtml)${ssionssisilenterrorsonssitypestextshtml}#对""启用365bet最新官网备用网站_365bet盘口编辑器_澳门365bet下载均衡location{proxypasshttp:mysvrproxyredirectoffproxysetheaderHost$hostproxysetheaderXRealIP$remoteaddrproxysetheaderXForwardedFor$proxyaddxforwardedforclientmaxbodysizemclientbodybuffersizekproxyconnecttimeoutproxysendtimeoutproxyreadtimeoutproxybuffersizekproxybufferskproxybusybufferssizekproxytempfilewritesizek}#设定查看Nginx状态的地址locationNginxStatus{stubstatusonaccesslogonauthbasic"NginxStatus"}}}呵呵我是华丽的分割线!二、高级配置、查看Nginx运行状态输入地址http:NginxStatus输入验证帐号密码即可看到类似如下内容Activeconnections:serveracceptshandledrequestsReading:Writing:Waiting:第一行表示现在活跃的连接数第三行的第三个数字表示Nginx运行到、配置虚拟主机在http下添加server来增加虚拟主机代码如下server{listenservernamehostcomrootmyserverhostlocation~*(php|php)${#fastcgipassunix:tmpphpcgisockfastcgipass:fastcgiindexindexphpincludefcgiconf志存高远脚踏实地骆超飞}}server{listenservernamehostcomrootmyserverhostlocation~*(php|php)${#fastcgipassunix:tmpphpcgisockfastcgipass:fastcgiindexindexphpincludefcgiconf}}、配置Nginx虚拟主机(防盗链及expires设置)server{listenservernamebbslinuxtoneorgwwwlinuxtoneorgindexindexhtmlindexphpindexhtmrootdatawwwwwwrootltbbs#accesslogvarlognginxaccessbbsredocncomlogcombinedlocation{if(!e$requestfilename){rewrite^archiver((fid|tid)whtml)$archiverindexphp$lastrewrite^forum()()html$forumdisplayphpfid=$page=$lastrewrite^thread()()()html$viewthreadphptid=$extra=pageD$page=$lastrewrite^space(username|uid)()html$spacephp$=$lastrewrite^tag()html$tagphpname=$lastbreak}}#Preventinghotlinkingofimagesandotherfiletypeslocation~*^(gif|jpg|png|swf|flv|rar|zip)${validreferersnoneblockedservernames*linuxtoneorghttp:localhostif($invalidreferer){rewrite^http:bbslinuxtoneorgimagesdefaultlogogifreturn}}#Addexpiresheaderforstaticcontentlocation~*(js|css|jpg|jpeg|gif|png|swf)${if(f$requestfilename){rootdatawwwwwwrootltbbsexpiresdbreak}}#supportphplocation~*php${includeenablephpconf}}、Nginx搭建下载站点限制并发数和速率viusrlocalnginxconfvhostsdownredocncomconflimitzoneone$binaryremoteaddrmserver{listenservernamedownredocncom志存高远脚踏实地骆超飞indexindexhtmlindexhtmindexphprootdatawwwwwwrootdownerrorpageindexphp#redirectservererrorpagestothestaticpagexhtmlerrorpagexhtmllocation=xhtml{roothtml}#Zonelimitlocation{limitconnonelimitratek}#servestaticfileslocation~^(images|javascript|js|css|flash|media|static){rootdatawwwwwwrootdownexpiresd}}、如何实现Nginx身份验证mkdirusrlocalnginxconfhtpasswd#创建存放密码的目录usrlocalapachebinhtpasswdcusrlocalnginxconfhtpasswdtongjiadminserver{location~^(tongji){rootdatawwwwwwrootcountauthbasic"LTCOUNTTongJi"authbasicuserfileusrlocalnginxconfhtpasswdtongji}}、如何实现Nginx目录列表在相关虚拟主机配置文件加入如下设置即可location{autoindexon}、修改Nginx的header伪装服务器cdnginxsrccore#defineNGINXVERSION""#defineNGINXVER"LTWS"NGINXVERSION重新编译nginx即可查看一下效果:rootcount~#curlIhttp:bbslinuxtoneorgHTTPOKServer:LTWSDate:Mon,Jun::GMTContentType:texthtmlcharset=gbTransferEncoding:chunkedConnection:keepaliveSetCookie:ltsid=cJNFTexpires=Mon,Jun::GMTpath=SetCookie:ltonlineusernum=expires=Mon,Jun::GMTpath=

声明:本文由(Nginx运维与架构)版权所有,禁止转载,文章链接:http://www.nd9p.com/12804.html