You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在IIS 10中将域名子目录部署到不同服务器?

Can I host a subdirectory on a different server with 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:

    1. Open IIS Manager on Server A, navigate to your main site (www.mydomain.com).
    2. Select the URL Rewrite feature, then click Add Rule(s) in the right-hand pane.
    3. Choose the Reverse Proxy template from the list.
    4. In the dialog, enter the backend address of Server B (e.g., http://192.168.1.100 or http://serverb.mydomain.local—use HTTPS if Server B is configured for it).
    5. Now, tweak the rule to only target the /admin path:
      • 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 /admin and passes it to Server B.
    6. 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.
  • Pro tip: To preserve the original host header (so Server B sees www.mydomain.com instead of Server A's address), go to the ARR proxy settings in IIS Manager, check Preserve Host Header under the Proxy tab.

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 ping or curl from 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/admin and verify it loads content from Server B, while the main site still loads from Server A.

内容的提问来源于stack exchange,提问作者Ryan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:07:39