Tag Archives: php
nginx防hashdos模块使用帮助
经过上周一周朋友们帮忙测试和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; …
nginx防hashdos模块释出
2012.1.7 更新 编译的时候推荐使用nginx-1.0以上版本,不要加--with-debug参数编译,(感谢agentzh指出)。 hashdos这个事,严格意义上不是各种语言的错了(不过perl的确处理得很好),但是用nginx来擦屁股要干净些。 借鉴tomcat的作法,实现了下面这个nginx-http-hashdos-module,通过设置hashdos(默认on)的开关和body_max_count(默认值1000),对nginx后面的服务进行安全防护,相比对php或者java进行patch,这或许是最好的办法了。 nginx-http-hashdos-module项目地址 https://github.com/54chen/nginx-http-hashdos-module 如何使用 1.下载zip后保存到一个目录,如~/nginx-http-hashdos-module。 2.cd nginx-1.0.9/ 3.重新编译和安装nginx ./configure --prefix=/opt/soft/nginx --with-pcre --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=/path_to/nginx-http-hashdos-module/ && make && make install 4.配置打开: hashdos on; body_max_count
quercus记录:php使用连接池访问数据库
上周记录了如何用quercus建立混合型项目。 http://www.54chen.com/php-tech/quercus-notes-php-java-mixed-projects.html 这里来说说与数据库的访问,使用jndi得到连接池的好处。 JNDI (Java Naming and Directory Interface)是SUN公司提供的一种标准的Java命名系统接口,JNDI提供统一的客户端API,通过不同的访问提供者接口JNDI SPI的实现,由管理者将JNDI API映射为特定的命名服务和目录系统,使得Java应用程序可以和这些命名服务和目录服务之间进行交互。 正题 在quercus中可以随意使用mysql_connect与mysql_pconnect两个方法来连接数据库。 当在web.xml定义得有database相关的消息时,mysql_connect与mysql_pconnect都会自动忽略里面的参数设置,直接使用web.xml的定义。 添加jndi设置: vim WEB-INF/web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://caucho.com/ns/resin"> <description>truth application</description>
quercus记录:php和java的混合型项目建立手记
创业公司参与项目的人口众多、背景不一,目前市场上的主流方向为php与java,很多时候java工程师恨铁不成钢,php工程师也无可奈何。于是便有了此文,讲述如何使用quercus创建php java混合型项目。 quercus是什么? quercus是Caucho公司针对php语言的java实现,100%完成了php5的解析。是resin内建支持的功能。同时,因为使用了resin,使得php可以很容易得到连接池、分布式session、负载均衡等功能。使用resin的php项目可以更加安全,不存在很多fastcgi的问题。 性能如何? 官方:用mediawiki与drupal来做实验,要比mod_php快4倍。 有一个编译选项,在resin专业版里支持,可以把php转成java class,得到更高性能。 新建一个java项目混合php项目 web.xml是关键,里面声明了*.php文件的访问都以com.caucho.quercus.servlet.QuercusServlet来执行。 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun
redmine极速安装手记
Redmine是用Ruby开发的基于基于web的项目管理软件,是用ROR框架开发的一套跨平台项目管理系统,系统通过“项目(Project)”的形式把成员、任务(问题)、文档、讨论以及各种形式的资源组织在一起,大家参与更新任务、文档等内容来推动项目的进度,同时系统利用时间线索和各种动态的报表形式来自动给成员汇报项目进度。 机器环境: ubuntu 10.04 dell optiplex 380 root权限下操作 1)apt-get install mysql-client mysqld-server 2)进mysql: create database redmine_default; GRANT all ON redmine_default.* TO root@'%' IDENTIFIED BY 'miliao'; FLUSH PRIVILEGES ; 3)apt-get install redmine redmine-mysql subversion libapache2-mod-passenger 4)ln -s /usr/share/redmine/public /var/www/redmine 5)a2enmod passenger …
[nginx]如何在access log中记录post请求的参数
移动互联网行业开发过程中,服务端经常会需要检查是否收到请求,收到什么样的请求,最简单的办法就是看nginx的access log,常见的nginx配置中access log一般都只有GET请求的参数,而POST请求的参数却不行。 http://wiki.nginx.org/NginxHttpCoreModule#.24request_body $request_body This variable(0.7.58+) contains the body of the request. The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass. 正如上文件所示,只需要使用$request_body即可打出post的数据,在现存的server段加上下面的设置即可: log_format access '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" "$http_user_agent" $http_x_forwarded_for'; …
ubuntu下Empathy十月起无法登录msn的解决办法
作为ubuntu深度用户,我(54chen)在几个星期前就有网友来问过,msn登录常常会挂掉,甚至到现在已经无法再登录,受影响的范围很广,最新的10.10也是一样的,原因可能是msn单方面更新了接口,下面提供一种解决办法(以10.04lts Empathy 2.30.1.1 为例): #vim /usr/share/pyshared/papyon/service/description/SingleSignOn/RequestMultipleSecurityTokens.py 找到第24行注释掉: #CONTACTS = ("contacts.msn.com", "?fs=1&id=24000&kv=7&rn=93S9SWWw&tw=0&ver=2.1.6000.1") 修改为: CONTACTS = ("contacts.msn.com", "MBI") (请勿复制,引号有转义) 然后重启,恭喜你msn高昂登录。 附: ubuntu下empathy的msn群显示昵称 点击下载我修改过的文件: http://www.54chen.com/RequestMultipleSecurityTokens.py.gz gunzip RequestMultipleSecurityTokens.py.gz sudo cp RequestMultipleSecurityTokens.py /usr/share/pyshared/papyon/service/description/SingleSignOn/
nginx.conf控制指定的代理ip和ip访问的设置手记
工作中有一次用到利用nginx的配置来让只有公司ip的访问才能打开指定的后台url,于是有了下面的记录。 在nginx中if很弱,http://www.nginxcn.com/doc/standard/httprewrite.html,基本上不能写太复杂的条件或者是嵌套。 因为公司我(54chen)网络的设置,过去打到服务器的ip有可能是几个ip,同时也有可能是代理的ip,所以在if判断的时候,可能有多个条件。 location /administrator { #log_format www_54chen_com '$remote_addr - $remote_user [$time_local] $request ' # '"$status" $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; # access_log /data/www.log www_54chen_com; set $fuck 0; if ($remote_addr = '1.1.1.1'){ set $fuck 1; } if ($remote_addr = …
ubuntu 10.04 LTS版本下的Empathy MSN群聊显示昵称方法
1.关系普及 Empathy是个托,python-papyon是个python实现的msn库,telepathy-butterfly是个完成msn功能的python客户端。 2.修改办法 sudo vim /usr/share/pyshared/papyon/conversation.py 查找 if message_type == 这个字符串 找到内容为: if message_type == 'text/plain': msg = ConversationMessage(unicode(message.body, message_encoding), TextFormat.parse(message_formatting), self.__last_received_msn_objects) try: display_name = message.get_header('P4-Context') 将if判断后try之前中间定义msg这一堆内容修改为如下: try: msg = ConversationMessage(unicode("["+message.get_header('P4-Context')+"]"+message.body, message_encoding), TextFormat.parse(message_formatt
[警示]Nginx + PHP CGI的安全漏洞:fix_pathinfo
如果你正在使用nginx+php,请关注。 表像: 具体的重现过程,用php代码修改后缀名后上传,比如说www.xxx.com/1.jpg,访问的时候用www.xxx.com/1.jpg/xxx.php 这段jpg代码将会被执行!!! http://docs.php.net/manual/zh/ini.core.php cgi.fix_pathinfo "1" PHP_INI_ALL 从 PHP 4.3.0 起可用 请注意:默认为1 解决办法: 1.修改php.ini中的cgi.cgi.fix_pathinfo为0(即使你在php.ini中没有搜到,也要设置,没有搜到表示默认为1) 2.判断文件上传类型时使用严格的判断,至于怎么判断,参见:http://www.54chen.com/php-tech/php-upload-file-types-to-determine-the-complete-program-and-php-nginx-upload-size-and-complete-control-program.html 3.把nginx的判断正则修改为去除/ if ( $fastcgi_script_name ~ \..*\/.*php ) { return 403; } 鸟哥在http://www.laruence.com/2010/05/20/1495.html一文中提及此事。
SEARCH
Update
- 54chen Twitter memo 2012-02-12
- 人肉解析riak_admin join
- go语言安装手记
- 54chen Twitter memo 2012-02-05
- Riak Core说明
- maven库nexus拖不到jar包小记
- 服务接入层小结
- 54chen Twitter memo 2012-01-15
- nginx防hashdos模块使用帮助
- 54chen Twitter memo 2012-01-08
- nginx防hashdos模块释出
- 54chen Twitter memo 2012-01-01
- 水煮鱼杯2011年度不得不总结的十件事
- 年终攻击hashDos-哈希表多碰撞实现拒绝服务-破解办法
- 54chen Twitter memo 2011-12-25
