【发布时间】:2021-05-25 15:32:54
【问题描述】:
有没有办法在 IIS 上运行 Go Web 应用程序?
我找到了 azure 的设置,但它在我的开发机器上不起作用
这是 azure 的网络配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="d:\home\site\wwwroot\go\bin\go.exe"
arguments="run d:\home\site\wwwroot\server.go"
startupTimeLimit="60">
<environmentVariables>
<environmentVariable name="GOROOT" value="d:\home\site\wwwroot\go" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
【问题讨论】:
-
您必须从 IIS 反向代理到您的 Go 应用程序正在侦听的端口:weblogs.asp.net/owscott/…
-
Go 还有一个 FastCGI responder implementation 和 IIS 7+ 一个使用 FastCGI 后端 can be run as a FCGI application 的 Go 服务器。请注意,据传 FastCGI 响应器比 HTTP 慢一些,因此它可能按照@elithrar 的建议进行反向 HTTP 代理的性能更高。请注意,您的 Go 服务器可能会同时监听 HTTP 和 FCGI 请求。
-
Go 的 FastCGI 服务器客观上比较慢,所以我不推荐它。我必须挖掘基准,但 Go 团队承认它没有看到很多性能。由于需求低而进行调整。
-
另外,FastCGI 是 HTTP/1.1 之前的遗留物,它提供了大部分相同的好处。使用 FastCGI 的理由很少,除非它是您唯一的选择。
-
那么根本没有理由使用 IIS,除非你让它为你的应用程序所需的其他资产提供服务。