Nginx 重定向

之前由于脑子发热,把博客绑定到了www.heimonsy.com,而heimonsy.com跳转到www.heimonsy.com。现在发现基本已经没有人的博客用www.heimonsy.com或者blog.heimonsy.com之类的域名了。于是又改了回来,*.heimonsy.com跳转到heimonsy.com。Nginx的配置如下:

server {
        listen 80;
        server_name *.heimonsy.com;
        rewrite ^/(.*) http://heimonsy.com/$1 permanent;
        access_log off;
}

permanent表示301永久重定向。
如果需要302可改为redirect

Centos Iptables 端口转发配置

首先,改/etc/sysctl.confet.ipv4.ip_forward = 1(本来是0)
命令:echo 1 > /proc/sys/net/ipv4/ip_forward

将本地的5231端口转发到192.168.1.101:5231进行如下配置
编辑iptables文件:vim /etc/sysconfig/iptables

*filter
#这一行放在*filter块
-A INPUT -p tcp -m tcp --dport 5231 -j ACCEPT  
# 下面两行放在*nat块
-A PREROUTING -p tcp -m tcp --dport 5231 -j DNAT --to-destination 192.168.1.101
-A POSTROUTING -p tcp -m tcp --dport 5231 -j MASQUERAD
COMMIT

接下来重启network 和 iptables

service network restart
service iptables restart

这样转发配置就完成了

也可以通过命令行来配置,下面这个命令式将本机的21端口转发到10.1.1.2的21端口:
iptables -t nat -A PREROUTING -p tcp --dport 21 -j DNAT --to 10.1.1.2:21