十一 24

想想做web已经一年半了,还没有系统的看过web的基础协议。
所以找了rfc2616的pdf版本,准备详细了解一下。

中文版也是有的,也曾下载看过,不过翻译质量实在不敢恭维。
还是和英文书一样,看原版吧。

非常有论文风格的一个标准。
一开始先是下定义,不过有几个定义我反复看了几次,还是不清楚具体的区别。

proxy
An intermediary program which acts as both a server and a client for the purpose of making requests on behalf
of other clients. Requests are serviced internally or by passing them on, with possible translation, to other
servers. A proxy MUST implement both the client and server requirements of this specification. A “transparent proxy” is a proxy that does not modify the request or response beyond what is required for proxy authentication and identification. A “non-transparent proxy” is a proxy that modifies the request or response in order to provide some added service to the user agent, such as group annotation services, media type transformation, protocolreduction, or anonymity filtering. Except where either transparent or non-transparent behavior is explicitly stated, the HTTP proxy requirements apply to both types of proxies.
gateway
A server which acts as an intermediary for some other server. Unlike a proxy, a gateway receives requests as if it were the origin server for the requested resource; the requesting client may not be aware that it is
communicating with a gateway.
tunnel
An intermediary program which is acting as a blind relay between two connections. Once active, a tunnel is not considered a party to the HTTP communication, though the tunnel may have been initiated by an HTTP request. The tunnel ceases to exist when both ends of the relayed connections are closed.

有些实际例子就好了。

Tagged with:
十一 17

1.首先查看端口状态,可以使用命令
-># netstat -an   (若查看某个端口,后面可接端口号)

2.检查服务状态使用chkconfig,如检查SSH,
-># chkconfig sshd

如为off,则需要打开系统服务的端口,可用chkconfig on命令,如打开SSH,
-># chkconfig ssh on service xinetd restart

3.防火墙开放端口:

(方法一:)

i. 进入 /etc/sysconfig/ 目录,用 vi 命令编辑 SuSEfirewall2 文件,
-># vi SuSEfirewall2
在文件中找到FW_SERVICES_EXT_TCP,在其后面加上服务名或者是服务对应的端口,如SSH,
FW_SERVICES_EXT_TCP=”ssh” 或 FW_SERVICES_EXT_TCP=”22″
保存之后退出。

ii. 重启防火墙,以使配置生效,
-># rcSuEfirewall2 restart

(方法二:)

i. 进入 /etc/sysconfig/ 目录, 查找 iptables 文件。若不存在,则新建一个名为iptables文件,

-># touch iptables

ii. 在iptables文件中添加如下,以便打开端口,如:

-A RH-Firewall-1-INPUT -p tcp -m state -m tcp –dport 22 –state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp –dport 80 –state NEW -j ACCEPT

iii. 重起iptalbes服务:service iptables restart  或重启机器。

iptables命令详解:http://www.diybl.com/course/6_system/linux/Linuxjs/200888/135058.html

(方法三:)

引自:http://hi.baidu.com/wzj423/blog/item/81e8d2f9525b995d242df23a.html 部分内容

创建/etc/init.d/firewall文件:

vi /etc/init.d/firewall

放到/etc/init.d下的原因是方便自动启动。

脚本如下:

#!/bin/bash
# This program is used to use start my iptables.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:~/bin
export PATH

case “$1″ in
start)
echo -n “Staring FireWall …”
# /sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -A INPUT -i lo -j ACCEPT

/sbin/iptables -A INPUT -p tcp -m tcp –dport 22 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -m tcp –dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p all -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -p all -m state –state INVALID,NEW -j DROP
echo “OK”

;;
stop)
echo -n “Stop FireWall … ”
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -Z
echo “OK”
;;
restart)
/etc/init.d/firewall stop
/etc/init.d/firewall start

echo “Restart FireWall OK”
;;
*)
echo “Usage: $0 {start|stop|restart}”
esac

exit 0

如果想新开端口,直接修改start部分即可。

测试firewall是否能正常工作:

/etc/init.d/firewall restart

没有问题。

配置firewall随系统自动启动:

cd /etc/init.d
update-rc.d firewall defaults 01

01表示启动优先级,让系统刚启动时就立即启动防火墙规则,可修改所有的K01为K99,在关机或重启服务器时最后停止防火墙服务。

另:
ubuntu 下开发端口:http://wiki.ubuntu.org.cn/IptablesHowTo

Tagged with:
十一 06
Tagged with:
preload preload preload

无觅相关文章插件,快速提升流量