此脚本经过测试且正在使用中, 在安装的时候需要注意相关的路径:

#! /bin/sh
 
# Description: Startup script for webserver on CentOS. cp it in /etc/init.d and
# chkconfig --add nginx && chkconfig nginx on  
# then you can use server command control nginx
#
# Author: yangqian http://opkeep.com
# chkconfig: 2345 08 99
# description: Starts, stops nginx
 
set -e
 
PATH=$PATH:/usr/local/nginx/sbin/
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
 
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
 
d_start() {
  $DAEMON -c $CONFIGFILE || echo -n " already running"
}
 
d_stop() {
  kill -QUIT `cat $PIDFILE` || echo -n " not running"
}
 
d_reload() {
  kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}
 
case "$1" in
  start)
   echo -n "Starting $DESC: $NAME"
   d_start
   echo "."
 ;;
  stop)
   echo -n "Stopping $DESC: $NAME"
   d_stop
   echo "."
 ;;
  reload)
   echo -n "Reloading $DESC configuration..."
   d_reload
   echo "reloaded."
  ;;
  restart)
   echo -n "Restarting $DESC: $NAME"
   d_stop
   sleep 1
   d_start
   echo "."
 ;;
  *)
   echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
   exit 3
 ;;
esac
 
exit 0
浏览:39 次标签:nginx / shell / 脚本阅读全文

    在Linux环境下,利用了Nginx的强势—反向代理,结果导致用request.getRemoteAddr()获取的IP均为公司的代理服务器的IP,日志记录严重不准确!
    大家都知道在服务器端获取客户端的IP地址的方法是:request.getRemoteAddr(),这种方法在大部分情况下都是有效的。
       但是在通过了Nginx,Squid等反向代理软件就不能获取到客户端的真实IP地址了。
      如果使用了反向代理软件,例如将http://192.168.101.88:80/的URL反向代理为http://pay.kedou.com/的URL时,用request.getRemoteAddr()方法获取的IP地址是:127.0.0.1 或 192.168.101.88,而并不是客户端的真实IP。
   原来是client端直接请求服务端,走A路线请求,这时候通过request.getRemoteAddr()方法可以准备的获取客户端的IP。但是做了代理之后呢,client端不是直接请求服务端,而是走B线路请求代理服务器,由代理器去请求服务端,这时候服务端通过request.getRemoteAddr()方法拿到的理所当然是
代理服务器的地址了。

浏览:58 次标签:linux / nginx / ip / squid阅读全文

nginx-logo.png经过上周一周朋友们帮忙测试和bug fix,nginx_http_hashdos_module已经达到可以线上使用的水平,下面是使用记录。
下载

#wget --no-check-certificate https://github.com/54chen/nginx-http-hashdos-module/zipball/master
#mv master nginx_hashdos.zip
#unzip nginx_hashdos.zip


编译安装


#tar zxvf nginx-1.0.xx.tar.gz
#cd nginx-1.0.xx/
#./configure --prefix=/opt/soft/nginx --with-pcre --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=../54chen-nginx-http-hashdos-module-f84d909
#make && make install


配置注意事项
在http段,增加如下:


hashdos on;
body_max_count 1000;


在各自的location段,要按照业务情况来加:


client_body_buffer_size 2m;
client_max_body_size 2m;


*上述两个值一定要相等。

如果是普通的discuz,上传上限是1m的,可以修改为1m。
如果是没有上传功能的普通网站,建议修改为512k。


原创文章如转载,请注明:转载自五四陈科学院[http://www.54chen.com]
本文链接: http://www.54chen.com/_linux_/nginx-hashdos-help.html

浏览:131 次标签:nginx / hashdos阅读全文