LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2232|回复: 3

vsftpd-1.1.3配制实例之四:VIRTUAL_HOSTS

[复制链接]
发表于 2003-6-1 09:25:14 | 显示全部楼层 |阅读模式
README

This example shows how you might set up virtual hosts. Virtual hosting is
where different clients access your machine on different IP addresses (virtual
IPs) and get redirected to different ftp sites.

For example, if your machine responds to two IPs - 127.0.0.1 and 127.0.0.2,
you could have the two different IPs represent two totally different FTP sites.

For this example, we are going to build on the "INTERNET_SITE" example.

Step 1) Set up a virtual IP address.

ifconfig eth0:1 192.168.1.10 up
(the standard IP address is 192.168.1.2)
(note - this isn't quite complete, the route for local connects hasn't been
added, but it will do for now)


Step 2) Create a user / location for the new virtual site.

useradd -d /var/ftp_site2 ftp_site2
chown root.root /var/ftp_site2
chmod a+rx /var/ftp_site2
umask 022
mkdir /var/ftp_site2/pub
echo "test" > /var/ftp_site2/pub/content


Step 3) Modify the existing site to respond to the primary IP.

Edit /etc/xinetd.d/vsftpd, and add the config line:

bind = 192.168.1.2


Step 4) Create the new site, responding on the virtual IP.

cp /etc/xinetd.d/vsftpd /etc/xinetd.d/vsftpd2

Edit vsftpd2, and change
- The bind line to refer to the IP address 192.168.1.10
- Add the line
server_args = /etc/vsftpd_site2.conf

This launches this FTP site with a different vsftpd configuration file.

cp /etc/vsftpd.conf /etc/vsftpd_site2.conf

Add two lines:
ftp_username=ftp_site2
ftpd_banner=This is the alternative FTP site.


Step 5) Restart xinetd and test!

/etc/rc.d/init.d/xinetd restart

[chris@localhost vsftpd]$ ftp 192.168.1.2
Connected to 192.168.1.2 (192.168.1.2).
220 ready, dude (vsFTPd 1.1.0: beat me, break me)
Name (192.168.1.2:chris): [chris@localhost vsftpd]$
[chris@localhost vsftpd]$ ftp 192.168.1.2
Connected to 192.168.1.2 (192.168.1.2).
220 ready, dude (vsFTPd 1.1.0: beat me, break me)
Name (192.168.1.2:chris):
530 This FTP server is anonymous only.
Login failed.
ftp> quit
221 Goodbye.

[chris@localhost vsftpd]$ ftp 192.168.1.10
Connected to 192.168.1.10 (192.168.1.10).
220 This is the alternative FTP site.
Name (192.168.1.10:chris):
530 This FTP server is anonymous only.
Login failed.
ftp>
发表于 2003-10-10 00:06:38 | 显示全部楼层
standalone下该怎么做呢?
我把lesten打开,机子设两个ip,发现就可以了.这样做正确吗?
lesten_address怎么设呢?
我的机子设有两个ip:10.17和10.168
把lesten_address=10.17后,就不行了.
发表于 2003-10-10 02:30:23 | 显示全部楼层
空闲时翻译的,时间关系就捡个短篇:

vsftpd-1.1.3配制实例之四:虚拟主机(VIRTUAL_HOSTS)

README

本例子引导你如何建立虚拟主机。虚拟主机可以理解为: 不同地域的 ftp 客户端通过不同的 IP
地址(虚拟 IP 地址) 来访问你的服务器,并且重定向到运行在该机器中的不同 ftp 站点。

例如,如果你的机器能响应两个 IP 地址 - 127.0.0.1 和 127.0.0.2,
可以让这两个不同的 IP 地址分别代表两个完全不同的 FTP 站点。

在本例中,我们将要建立一个基于 "英特网的站点(INTERNET_SITE") 的范例。

第一步) 设置虚拟 IP 地址

ifconfig eth0:1 192.168.1.10 up

(标准 IP 地址(即主IP) 是 192.168.1.2)
(注意 - 以上步骤并不完整,我们暂时还没有为它添加到本地连接的路由,不过目前来说足够了)

第二步) 为新的虚拟站点创建一个用户 / 站点位置

useradd -d /var/ftp_site2 ftp_site2
chown root.root /var/ftp_site2
chmod a+rx /var/ftp_site2
umask 022
mkdir /var/ftp_site2/pub
echo "test" > /var/ftp_site2/pub/content


第三步) 修改已有的站点配置文件以响应 主IP 地址。

编辑 /etc/xinetd.d/vsftpd, 增加配置行:
bind = 192.168.1.2

第四步) 建立新站点配置文件,让它响应 虚拟IP 地址

cp /etc/xinetd.d/vsftpd /etc/xinetd.d/vsftpd2
编辑 vsftpd2 文件,如下修改
- 让 bind 行指向 IP 地址 192.168.1.10
- 增加一行
server_args = /etc/vsftpd_site2.conf
表示让这个虚拟 FTP 站点运行一份和主站不同的 vsftpd 配置文件。

cp /etc/vsftpd.conf /etc/vsftpd_site2.conf
增加两行:
ftp_username=ftp_site2
ftpd_banner=This is the alternative FTP site.(译:这是一个候选 FTP 站点)


第5步) 重启 xinetd 服务并测试!

/etc/rc.d/init.d/xinetd restart

[chris@localhost vsftpd]$ ftp 192.168.1.2
Connected to 192.168.1.2 (192.168.1.2).
220 ready, dude (vsFTPd 1.1.0: beat me, break me)
Name (192.168.1.2:chris): [chris@localhost vsftpd]$
[chris@localhost vsftpd]$ ftp 192.168.1.2
Connected to 192.168.1.2 (192.168.1.2).
220 ready, dude (vsFTPd 1.1.0: beat me, break me)
Name (192.168.1.2:chris):
530 This FTP server is anonymous only.
Login failed.
ftp> quit
221 Goodbye.

[chris@localhost vsftpd]$ ftp 192.168.1.10
Connected to 192.168.1.10 (192.168.1.10).
220 This is the alternative FTP site.
Name (192.168.1.10:chris):
530 This FTP server is anonymous only.
Login failed.
ftp>
发表于 2003-10-10 09:03:49 | 显示全部楼层
太好了,终于有同志在这里说点深有体会的东东了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表