解决nginx 503 Service Temporarily Unavailable方法示例

解决nginx 503 Service Temporarily Unavailable方法示例

最近网站刷新后经常出现503 Service Temporarily Unavailable错误,有时有可以,联想到最近在nginx.conf里做了单ip访问次数限制,(limit_req_zone $binary_remote_addr zone=allips:20m rate=20r/s;) 把这个数量放大后在刷新发现问题解决。(还顺便把这个改大了 limit_req zone=allips burst=50 nodelay;   )为了证实该问题,反复改动该数量测试发现问题确实在这。这个数量设得太小有问题,通过fiddler发现web页面刷新一下,因为页面上引用的js,css,图片都算一个连接。所以单个页面刷新下就有可能刷爆这个限制,超过这个限制就会提示503 Service Temporarily Unavailable。
Nginx配置文件详解

Nginx配置文件详解

Nginx的主配置文件是nginx.conf,这个配置文件一共由三部分组成,分别为全局块、events块和http块。在http块中,又包含http全局块、多个server块。每个server块中,可以包含server全局块和多个location块。在同一配置块中嵌套的配置块,各个之间不存在次序关系。
Nginx服务器如何设置url链接

Nginx服务器如何设置url链接

  对于LNMP这样架构的网站来说,一般都是基于php框架开发,php框架一般都会讲究优雅链接,比如Laravel,CodeIgniter,ThinkPHP等都是支持这种链接模式的,在服务器配置上也叫作url重写,目前框架大都采用单一入口的index.php然后基于MVC模式的话一般是/index.php/Model/function这种请求方式,所以如果能去掉index.php入口文件整个url就显得简洁美观,和Python、Java等开发的网站url模式统一,Apache和nginx都支持这种url的模式,下面说一下nginx配置的方式
nginx安装及配置支持php的教程(全)

nginx安装及配置支持php的教程(全)

pcre-7.8.tar.gz  正则表达式下载地址:  nginx-0.7.26.tar下载地址:   php-5.2.6.tar.bz2下载地址:  php-5.2.6-fpm-0.5.9.diff.gz  php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi下载地址:  注:PHP的版本要和fpm的版本一致mysql-5.0.67.tar.gz  Discuz!_6.0.0_SC_UTF8.zip1、安装pcre
ubuntu系统中nginx启动脚本

ubuntu系统中nginx启动脚本

代码如下:#! /bin/sh### BEGIN INIT INFO# Provides:          nginx# Required-Start:    $remote_fs $syslog# Required-Stop:     $remote_fs $syslog# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: nginx init.d dash script for Ubuntu or other *nix.# Description:       nginx init.d dash script for Ubuntu or other *nix.### END INIT INFO#------------------------------------------------------------------------------# nginx - this Debian Almquist shell (dash) script, starts and stops the nginx#         daemon for Ubuntu and other *nix releases.## description:  Nginx is an HTTP(S) server, HTTP(S) reverse #               proxy and IMAP/POP3 proxy server.  This #               script will manage the initiation of the #               server and it's process state.## processname: nginx# config:      /usr/local/nginx/conf/nginx.conf# pidfile:     /usr/local/nginx/logs/nginx.pid# Provides:    nginx## Author:  Jason Giedymin#          <jason.giedymin AT gmail.com>.## Version: 3.5.1 11-NOV-2013 jason.giedymin AT gmail.com# Notes: nginx init.d dash script for Ubuntu.# Tested with: Ubuntu 13.10, nginx-1.4.3# # This script's project home is:#   http://github.com/JasonGiedymin/nginx-init-ubuntu##------------------------------------------------------------------------------#                               MIT X11 License#------------------------------------------------------------------------------## Copyright (c) 2008-2013 Jason Giedymin, http://jasongiedymin.com## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#------------------------------------------------------------------------------
nginx关闭favicon.ico、robots.txt日志记录配置

nginx关闭favicon.ico、robots.txt日志记录配置

nginx日志最近发生大量访问favicon.ico无法找到的404错误日志,小编感觉很影响服务器性能,对于一个高并发的服务器每一个错误都会影响性能,所以需要关闭访问favicon.ico的日志记录功能。 代码如下:# 把以下配置放到 server {} 块.
Nginx中定义404页面并且返回404状态码的正确方法

Nginx中定义404页面并且返回404状态码的正确方法

前几天,一朋友出程序出问题却怎么查都没看出问题,于是让我帮它看看。其实它是ajax请求了很多个模板,然后把模板写到页面中。关键是所有请求的页面都是200正常状态码返回,表面上看没什么问题,实际上有些请求虽然返回200状态码,但给回的状态码是200。WebServer是nginx,直接告诉我应该他们配置了nginx的404错误页面,虽然请求不存在的资源可以成功返回404页面,但返回状态码确是200。
nginx中path模式配置示例

nginx中path模式配置示例

nginx服务器默认是不支持pathinfo模式的,即类似index.php/index形式的url会提示404。在这里,需要对nginx配置文件中需要开启pathinfo模式的server予以修改配置,修改nginx.conf文件如下:
Nginx下配置301重定向的正确方法例子

Nginx下配置301重定向的正确方法例子

之前给nginx做301重定向的时候经常会这样写: 代码如下: server {     listen       80;     server_name  www.jb51.net jb51.net;     if ($http_host = www.jb51.net) {         rewrite  (.*)  http://jb51.net$1;     }     ... } 实际标准的写法应该是 代码如下: server {     listen       80;     server_name www.jb51.net;     return       301 http://jb51.net$request_uri; }
针对OpenSSL安全漏洞调整Nginx服务器的方法

针对OpenSSL安全漏洞调整Nginx服务器的方法

1. 概述     当前爆出了Openssl漏洞,会泄露隐私信息,涉及的机器较多,环境迥异,导致修复方案都有所不同。不少服务器使用的Nginx,是静态编译 opensssl,直接将openssl编译到nginx里面去了,这就意味着,单纯升级openssl是没有任何效果,Nginx不会加载外部的 openssl动态链接库的,必须将nginx重新编译才可以根治。