能否在IIS 10中将域名子目录部署到不同服务器?
Absolutely, you can host www.mydomain.com/admin on Server B while keeping the main site www.mydomain.com on Server A using IIS 10. This is totally doable—here are the most practical methods to make it work:
Method 1: Reverse Proxy with ARR + URL Rewrite
This is the most reliable approach for cross-server subdirectory hosting, as it lets Server A act as a gateway that forwards requests for /admin to Server B.
First, install two required modules on Server A:
- Application Request Routing (ARR)
- URL Rewrite
You can get both via the IIS Manager's Web Platform Installer—just search for the module names and follow the installation prompts.
Once installed, set up the reverse proxy rule:
- Open IIS Manager on Server A, navigate to your main site (
www.mydomain.com). - Select the URL Rewrite feature, then click Add Rule(s) in the right-hand pane.
- Choose the Reverse Proxy template from the list.
- In the dialog, enter the backend address of Server B (e.g.,
http://192.168.1.100orhttp://serverb.mydomain.local—use HTTPS if Server B is configured for it). - Now, tweak the rule to only target the
/adminpath:- Edit the newly created rule, set the Pattern to
^admin/(.*)(this matches any request starting with/admin/). - Update the Rewrite URL to
http://serverb-address/{R:1}—the{R:1}captures the rest of the path after/adminand passes it to Server B.
- Edit the newly created rule, set the Pattern to
- If you're using HTTPS for the main site, make sure to enable SSL offloading in the ARR settings, and ensure Server B either has a valid SSL certificate or you configure Server A to handle SSL termination.
- Open IIS Manager on Server A, navigate to your main site (
Pro tip: To preserve the original host header (so Server B sees
www.mydomain.cominstead of Server A's address), go to the ARR proxy settings in IIS Manager, check Preserve Host Header under the Proxy tab.
Method 2: Virtual Directory with Network Share (Less Recommended)
If Server B's admin content is static or a simple ASP.NET app, you could create a virtual directory on Server A's main site that points to a network share on Server B. However, this comes with caveats:
- You'll need to set up proper file sharing permissions between Server A and Server B (use domain accounts or managed service accounts for security).
- This doesn't work well for dynamic apps that rely on server-side processing specific to Server B (like PHP or Node.js apps).
- Network latency or permission issues can cause unexpected downtime, so reverse proxy is almost always a better choice.
Key Things to Check
- Ensure Server A can reach Server B over the network—test with
pingorcurlfrom Server A to Server B's address to confirm connectivity. - Firewall rules on both servers should allow traffic on the ports you're using (80 for HTTP, 443 for HTTPS, or custom ports if needed).
- Test the setup thoroughly: visit
www.mydomain.com/adminand verify it loads content from Server B, while the main site still loads from Server A.
内容的提问来源于stack exchange,提问作者Ryan

