By Alejandro Villarreal
I recently did a deployment for which several sites and components needed to be deployed to the same machine, and we didn’t want to provide access through FTP to the whole disk, but to the specific folders where the components had to be deployed. At a first glance this sounded pretty easy: we created the required sites in IIS (each with a different hostname in its HTTP binding), added bindings for FTP in each site, configured a different host name for each of those bindings (for each site, the same hostname that the HTTP binding had), set up security for FTP, and started the FTP service and sites. I must also say that we had another site with an FTP binding that was configured to accept all other connections, by using a blank hostname.
But when we tried to access each of the named sites through FTP, we ended up getting to the same folder no matter what hostname we used. That folder was the one that the “catch all” FTP site (the one with the blank hostname) was pointing to.
After a bit of research, we found out that this is a known limitation of FTP. Even though IIS 7.0 allows you to specify different hostnames for each FTP site, the protocol itself doesn’t natively support it, so when you try to authenticate to an FTP site with a user and password, it isn’t smart enough to determine who should process the authentication request; in a way, it “forgets” about the hostname that you’re trying to access, and this –as we discovered– can have unexpected results.
It turns out that there are 2 workarounds for this:
1. Change the way in which you specify credentials when connecting to the site.
If “myftpsite.com” is one of the virtual hostnames specified in an FTP binding in IIS, instead of doing something like this:
You should do something like this:
ftp://myftpsite.com|user@myftpsite.com
Prepending the hostname and a pipe to the username should let you connect to the correct site. This workaround, however, might be incompatible with a couple of FTP clients that might not allow using pipes in the username.
2. Set the “useDomainAsHostName” property in IIS to true, so it automatically does it. This can be done by running the following command:
%windir%\system32\inetsrv\appcmd.exe set config -section:system.ftpServer/serverRuntime /hostNameSupport.useDomainNameAsHostName:"True" /commit:apphost
The second option seems more practical (I can’t see a reason why not to use it), but any of the two will let you connect to a specific virtual FTP site among all those defined in IIS.
Thanks for sharing such a great Blog. More people are hooked up in the Internet these days. Hence, online marketing can easily be achieved. website hosting service provider
ReplyDelete