Internet Information Service (IIS) can access data in Server Message Block (SMB) file systems in the same way as it accesses data in on-premises disks. IIS provides the web and FTP services to separate website storage from computing. This topic describes how to configure IIS to access a NAS file system.
Prerequisites
- An SMB file system is created and a mount target is created for the file system. For more information, see Create a file system and Create a mount target.
- WinSCP is installed.
Background information
Windows server is a popular platform that is used to build websites. A large number of users build websites on Windows Elastic Compute Service (ECS) instances and store the content resources of the website on a reliable and high-throughput SMB file system. In addition, the computing and storage resources support auto scaling based on specific business requirements.
The FTP service provided by IIS includes a wide range of requirements. A large number of website administrators remotely manage website content by using the FTP service. Meanwhile, a large number of Alibaba Cloud users want to transfer and share files between WANs and Alibaba Cloud by using the FTP service on Windows ECS instances.
In this example, IIS 7.5 (Windows Server 2008 R2) is used to describe how to use NAS to provide both the web service and FTP service for a Windows ECS instance. You can also use Server Load Balancer (SLB) to build a multi-server website that provides error tolerance. For more information, see What is SLB?
- The topic provides some security suggestions, but they are not a complete security solution. You must devise your own plans to secure your web services and data. For example, you can safeguard your system security by setting up firewalls, configuring security groups for ECS instances, and installing operating system patches. You can also safeguard your service security by using the security services of Alibaba Cloud.
- In this topic, a normal user named iss_user is used. We recommend that you access data as this user instead of the system administrator when you deploy FTP services or run IIS web services on Windows Server 2016.
Install Windows IIS
- In the Windows server, choose .
- In the left-side navigation pane of the Server Manager dialog box, click Roles. Then, click Add Roles.
- In the left-side navigation pane of the Add Roles Wizard, click Server Roles. Then, select Web Server (IIS).
- In the left-side navigation pane of the Add Roles Wizard, click Role Services. Then, select the role services that you want to install for the web server (IIS).
In addition to the default services, you must also select ASP and FTP Server to enable FTP services and demonstrate dynamic web pages by using scripts.
- Click Next and complete the installation as prompted.
Access the SMB file system
You can store your web resources and configuration files in the shared directory (myshare by default) of the SMB file system. You can configure the permission group of the SMB file system to make sure that the web server can read data from and write data to the file system.
- Open the File Explorer window and enter \\file-system-id.region.nas.aliyuncs.com\myshare in the address bar to access the SMB file system.
- file-system-id.region.nas.aliyuncs.com is the domain name of the mount target for the SMB file system. For more information about how to obtain the domain name of the mount target for an SMB file system, see View the endpoint of a mount target.
- myshare is the default shared directory of the SMB file system. You cannot change this directory.
- Create a subdirectory named www in the myshare directory of the SMB file system to store web page files of your website.
In this example, the static web page file index.html and the dynamic web page file test.asp are created in the myshare\www directory. The following sample code shows how to create the files:
- Index.html
<HTML> <HEAD> <TITLE>Hello World in HTML</TITLE> </HEAD> <BODY> <CENTER><H1>Hello World!</H1></CENTER> </BODY> </HTML>
Hello World!
is displayed in the static web page. - Test.asp
The current system time is displayed on the dynamic web page.<HTML> <BODY> This page was last refreshed on <%= Now() %>. </BODY> </HTML>
- Index.html
Set up the Windows IIS web service
- In the Windows server, choose .
- In the left-side navigation pane, choose Basic Settings. . Then, click
- In the Edit Site dialog box, set Physical path and click OK.
In the Physical path field, enter the storage path of web resources on NAS, for example, \file-system-id.region.nas.aliyuncs.com\myshare\www. file-system-id.region.nas.aliyuncs.com is the domain name of the mount target for the SMB file system. Replace the domain name with the actual value.
Note By default, you must use a user account and user group of IIS to access a network drive (for example, Z:\) mapped in the user session. You cannot directly access the mapped network drive as a Windows user. Otherwise, an access error may occur. - Optional:Modify the registry and add the iis_user user. To achieve the coordination of IIS and NAS, you must perform the following steps. For Windows Server 2016, you must modify the registry and add the iis_user user. For Windows Server 2019, you must modify the registry, add the iis_user user, and then run the New-SmbGlobalMapping command in PowerShell to mount the SMB file system. The command ensures that dynamic-link libraries (DLLs) can be loaded.
- Verify the settings.
Enter the local paths of the index.html and test.asp files in the address bar of your browser to open these files. If the following figures are displayed, IIS is running as expected. You can also configure security groups for your ECS instances and configure Windows Firewall to ensure access security.
Set up the Windows IIS FTP service
- In the Windows server, choose .
- Install the SSL certificate.
- Set up an FTP site.
- Set up the FTP firewall.
On the homepage, double-click FTP Firewall Support dialog box, specify Data Channel Port Range, and then click Apply.
- In the Server Manager window, restart the FTP service to validate the port range configurations.
- In the ECS console, configure the security group for the ECS instance to restrict the access of FTP clients. For more information, see Create a security group.
- Access the FTP site through the FTP client WinSCP.