域名+子域名的IIS部署

huangapple go评论80阅读模式
英文:

Domain + subdomain IIS deployment

问题

我有两个网站。第一个是asp.net core web ui。第二个是golang api。我还购买了域名foo.bar(例如)。我需要两个网站:

  1. foo.bar - asp.net ui
  2. api.foo.bar - go api

我该如何在iis上部署它们?
我的go服务器运行在8080端口。我尝试创建两个站点:

  1. 空主机名
  2. 主机名:api.foo.bar

foo.bar(ui)可以正常工作

我还尝试使用iis规则将api流量重定向到8080端口,但它不起作用。对于api.foo.bar,我只得到404错误。
唯一能正常打开的是在服务器浏览器中输入api.foo.bar:8080。

英文:

I have two web-sites. First is asp.net core web ui. Second is golang api. Also I have bought domain. foo.bar (for example). I need two web-sites:

  1. foo.bar - asp.net ui
  2. api.foo.bar - go api

How can I deploy that on iis?
My go-server works on port 8080. I tried create two sites:

  1. with blank hostname
  2. hostname: api.foo.bar

And foo.bar (ui) works

Also I tried redirect api-traffic to port 8080 with iis rule but it doesn't work. For api.foo.bar I just get error 404.
The only thing I get is that api.foo.bar:8080 opens correctly on from server's browser.

答案1

得分: 0

我创建了两个站点:

  1. foo.bar(用于 asp.net ui),主机名为空;
  2. 主机名:api.foo.bar,用于 API。

然后我在 web.config 中为 API 站点添加了重写规则:

<rewrite>
    <rules>
        <remove name="ReverseProxyInboundRule1" />
        <rule name="ReverseProxyInboundRule1" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <action type="Rewrite" url="http://localhost:8080/{R:0}" />
        </rule>
    </rules>
</rewrite>

一切都正常工作了。

英文:

I created two sites:

  1. foo.bar (for asp.net ui) with blank hostname;
  2. hostname: api.foo.bar for api.

Then I put rewrite-rule in web.config for api-site:

&lt;rewrite&gt;
    &lt;rules&gt;
      &lt;remove name=&quot;ReverseProxyInboundRule1&quot; /&gt;
      &lt;rule name=&quot;ReverseProxyInboundRule1&quot; patternSyntax=&quot;Wildcard&quot; stopProcessing=&quot;true&quot;&gt;
          &lt;match url=&quot;*&quot; /&gt;
          &lt;action type=&quot;Rewrite&quot; url=&quot;http://localhost:8080/{R:0}&quot; /&gt;
      &lt;/rule&gt;
    &lt;/rules&gt;
&lt;/rewrite&gt;

And everything worked

huangapple
  • 本文由 发表于 2023年6月6日 23:19:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76416119.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定