I have a Apache 2.2 web server running multiple HTTP and HTTPS virtual hosts, these work fine. Now I need to add an FTP vhost (there was one before!), and while
httpd -S displays all vhosts, only the default one gets to authorize requests. The mod_ftp manual says there is an FTP option to mod_ftp to redirect to proper vhost if the USER command provides a name, still logs arrive to first vhost's error log stating "no user found firstname.lastname@example.org". Respective config lines are here:
LoadModule ftp_module modules/mod_ftp.so Listen 21 ftp FTPOptions StripHostName VirtualHostByUser # this should allow selecting vhosts by hostname part in user@hostname NameVirtualHost *:21 #first vhost <VirtualHost *:21> FTP On ServerAdmin email@example.com DocumentRoot "d:/webroot/firsthost" ServerName www.firsthost.com ServerAlias firsthost.com ErrorLog "d:/webroot/logs/firsthost-ftp-error.log" CustomLog "d:/webroot/logs/firsthost-ftp-access.log" common SSLEngine off <Directory /> AllowOverride None Options Indexes -FollowSymLinks Order deny,allow Allow from all ForceType text/plain AuthType basic AuthBasicProvider file AuthUserFile "C:/server/apache/conf/extra/vhosts/firsthost-htpasswd.users" AuthName "firsthost.com FTP" Require valid-user </Directory> </VirtualHost> #second vhost - never gets to be addressed <VirtualHost *:21> FTP On ServerAdmin firstname.lastname@example.org DocumentRoot "d:/webroot/secondhost.com" ServerName www.secondhost.com ServerAlias secondhost.com SSLEngine off <Directory /> AllowOverride None Options Indexes -FollowSymLinks Order deny,allow Allow from all ForceType text/plain AuthType basic AuthBasicProvider file AuthUserFile "C:/server/apache/conf/extra/vhosts/secondhost-htpasswd.users" AuthName "secondhost.com FTP" # doesn't work anyway, we don't have hostname at AuthName state Require valid-user </Directory> ErrorLog "d:/webroot/logs/secondhost-error.log" CustomLog "d:/webroot/logs/secondhost-access.log" common </VirtualHost>
I use totalcmd to test, and it clearly states "firsthost.com FTP" gets advertised, and nothing can be made to switch to secondhost.com. As I understand the problem, while one host should really respond to connection, as FTP does not allow selecting host by name prior to authenticating, Apache should then change vhost definition used when receiving
USER email@example.com by FTP and review its vhosts to grab the correct password file and correct home directory. It doesn't. Any usable solutions, except for running FTP sites on different ports (where Apache would clearly differ between those hosts by connection request)?
PS: OS is Windows Server 2008R2, so building either Apache or mod_ftp from sources is out of reach. This can be a bug in particular executable set of Apache+mod_ftp. Apache responds with:
Server version: Apache/2.2.24 (Win32) Server built: Mar 1 2013 22:27:56
mod_ftp responds with: mod_ftp 0.9.6