我已将 IIS 配置为具有多个 FTP 站点,使用此处的说明:https://docs.microsoft.com/en-us/iis/publish/using-the-ftp-service/using-ftp-virtual-host-names-in-iis-7
请参阅下面我最终得到的配置。
在 IIS 中,我配置了基本身份验证并使用用户 mysite_ftp 进行“以...身份连接”,在测试设置时,我在身份验证和授权上都得到了绿色复选标记。
当我使用 Filezilla 尝试连接时,我收到以下日志:
尝试使用 VPS 主机名:h2746286.stratoserver.net
Status: Resolving address of h2746286.stratoserver.net
Status: Connecting to 85.214.200.30:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Command: USER tv_ftp
Response: 331 Valid hostname is expected.
Command: PASS ***********
Response: 503 Login with USER first.
Error: Critical error: Could not connect to server
尝试使用主机名:www.telefonievergelijken.nl
Status: Resolving address of www.telefonievergelijken.nl
Status: Connecting to 85.214.200.30:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Command: USER tv_ftp
Response: 331 Valid hostname is expected.
Command: PASS ***********
Response: 503 Login with USER first.
Error: Critical error: Could not connect to server
尝试使用主机名:ftp.telefonievergelijken.nl
Status: Resolving address of ftp.telefonievergelijken.nl
Status: Connecting to 85.214.200.30:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Command: USER tv_ftp
Response: 331 Valid hostname is expected.
Command: PASS ***********
Response: 503 Login with USER first.
Error: Critical error: Could not connect to server
应用程序主机配置
<sectionGroup name="system.ftpServer">
<section name="log" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
<section name="firewallSupport" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
<section name="caching" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
<section name="providerDefinitions" overrideModeDefault="Deny" />
<sectionGroup name="security">
<section name="ipSecurity" overrideModeDefault="Deny" />
<section name="requestFiltering" overrideModeDefault="Deny" />
<section name="authorization" overrideModeDefault="Deny" />
<section name="authentication" overrideModeDefault="Deny" />
</sectionGroup>
<section name="serverRuntime" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
</sectionGroup>
<sites>
<site name="othersite" id="2">
<application path="/" applicationPool=".NET v4.5">
<virtualDirectory path="/" physicalPath="E:\othersite\wwwroot" userName="othersite_web" password="[enc:IISCngProvider:b1dn9+We00KRNWUB6shbPm/hLtBOF2hOG9We5zVgaEmYL5C/fDLxDc3QH9Rnvi79SjeM+Rauk/bQWEBzJnw=:enc]" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:www.othersite.nl" />
<binding protocol="http" bindingInformation="*:80:othersite.nl" />
</bindings>
</site>
<site name="telefonievergelijken" id="3">
<application path="/" applicationPool=".NET v4.5">
<virtualDirectory path="/" physicalPath="E:\telefonievergelijken\wwwroot" userName="tv_web" password="[enc:IISCngProvider:x+PhGwZweUwR53tUgGTdEGui8k4gIJRASehxKVtsPoTtxNIA8aRe8WUwvdLuEdzSQicrJVDwen7e/C6x9qfiFyudqtZYwhXuo=:enc]" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:www.telefonievergelijken.nl" />
<binding protocol="http" bindingInformation="*:80:telefonievergelijken.nl" />
</bindings>
<traceFailedRequestsLogging enabled="true" directory="E:\IISData\LogFiles\FailedReqLogFiles" />
</site>
<site name="FTP-othersite" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="E:\othersite\wwwroot" />
</application>
<bindings>
<binding protocol="ftp" bindingInformation="127.0.0.1:21:" />
</bindings>
<ftpServer>
<security>
<ssl controlChannelPolicy="SslAllow" dataChannelPolicy="SslAllow" />
<authentication>
<basicAuthentication enabled="true" />
</authentication>
</security>
</ftpServer>
</site>
<site name="FTP-TV" id="4">
<application path="/">
<virtualDirectory path="/" physicalPath="E:\telefonievergelijken\wwwroot" userName="tv_ftp" password="[enc:IISCngProvider:xYxqamuKq02/xUcvZGTdEGui8gh3w6XT0hEegnCMZbVIxeWIOypRIZ1u8UAOG/AJg=:enc]" />
</application>
<bindings>
<binding protocol="ftp" bindingInformation="127.0.0.1:21:www.telefonievergelijken.nl" />
</bindings>
<ftpServer>
<security>
<ssl controlChannelPolicy="SslAllow" dataChannelPolicy="SslAllow" />
<authentication>
<basicAuthentication enabled="true" />
</authentication>
</security>
</ftpServer>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="E:\IISData\LogFiles" />
<traceFailedRequestsLogging directory="E:\IISData\LogFiles\FailedReqLogFiles" />
<ftpServer>
<logFile directory="E:\IISData\LogFiles\FTPLogs" />
<security>
<authentication>
<basicAuthentication enabled="false" />
</authentication>
</security>
</ftpServer>
</siteDefaults>
<applicationDefaults applicationPool="DefaultAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
更新 1
啊,我已将 127.0.0.1 IP 地址更改为我的 VPS 的外部 IP 地址。当我尝试连接时,ftp.telefonievergelijken.nl|tv_ftp
我收到日志错误:
Error: Could not connect to server
Status: Waiting to retry...
Status: Resolving address of ftp.telefonievergelijken.nl|tv_ftp
Status: Connection attempt failed with "EAI_NONAME - Neither nodename nor servname provided, or not known".
更新2
答案1
看起来您正在尝试使用当前未在 IIS 中任何 FTP 站点绑定中配置的主机名连接到 FTP 站点。
我仅根据您所包含的 Filezilla 的错误输出得出这一结论,因为您已经从输出中审查了主机名(即使是示例形式),所以没有太多可继续的信息。
您需要在 FTP 站点上配置一个绑定,该绑定与您用于连接 FTP 站点的主机名相匹配(无论是来自 Filezilla 还是任何其他 FTP 客户端)。
编辑:从您更新的帖子信息中,我注意到您对 FTP 站点的绑定确实配置不正确 - 您目前仅将 FTP 站点绑定到本地主机环回地址 (127.0.0.1)。您需要将其绑定到非环回地址,该地址可从外部路由。根据您的环境,这可能是您的外部 IP 地址(如果直接映射到服务器)或内部 IP 地址(如果您配置了 NAT)。根据目前的信息,我猜测您必须配置另一个 FTP 站点,该站点正在拦截这些请求并向您显示无效主机名错误。正确配置此 FTP 站点后,一切都应按预期运行。
此外,@Dre 的回答也很重要(所以你也应该赞成) - 如果你有多个 FTP 站点绑定到同一个 IP 地址,则需要在 FTP 客户端的“用户”字段中以以下格式指定主机名hostname|user
答案2
当配置了两个或多个主机名时,ftp 客户端必须在用户名中发送正确的虚拟主机名和用户名。用竖线符号分隔站点名称和用户:|
www.example.com|MyUser
因此,在您的 FTP 客户端中使用此用户名:
ftp.telefonievergelijken.nl|tv_ftp
答案3
我收到此错误是因为我将 IIS 10.0 实例配置为仅绑定在外部 URL 上。我的更正方法是添加一个与内部 IP 的额外绑定。与外部 URL 的 FTP 连接已成功解析。
答案4
如果您没有在端口 21(或您正在使用的任何端口)上托管多个主机,您也可以删除 IIS 设置下的绑定,即清除“站点绑定”>>“编辑站点绑定”下的“主机名”字段。此后,只要您的应用程序池具有相关权限,它应该就可以工作了。