在IIS上运行go web应用程序

在IIS上运行go web应用程序,iis,go,Iis,Go,有没有办法在IIS上运行Go web应用程序? 我找到了azure的设置,但它在我的开发机器上不起作用 这是azure的web配置: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers> <add name="httpplatformhandler" path="*" verb="

有没有办法在IIS上运行Go web应用程序?
我找到了azure的设置,但它在我的开发机器上不起作用
这是azure的web配置:

<?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无法正常工作,因为您需要安装一个单独的组件,名为HttpPlatformHandler module


反向代理或FastCGI是旧的方法,这种新方法不再需要它们。

HttpPlatformHandler模块对我不起作用。我发现非常有用,它使用ASP.NET核心模块代替

基本上,您需要像使用.net核心应用程序一样,使用“无托管代码”创建应用程序池。下面是web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath=".\YourGoApp.exe" />
    </system.webServer>
</configuration>


您必须将代理从IIS反转到您的Go应用程序正在侦听的端口:Go还有一个和IIS 7+Go服务器,使用FastCGI后端。请注意,有传言称FastCGI响应程序比HTTP的速度慢一些,因此按照@elithrar的建议执行反向HTTP代理可能会更有效。请注意,您的Go服务器可能会同时侦听HTTP和FCGI请求。Go的FastCGI服务器客观上比较慢,所以我不推荐它。我不得不挖掘基准点,但围棋队承认他们没有看到太多的表现。另外,FastCGI是HTTP/1.1之前的遗留产品,它提供了大部分相同的好处。使用FastCGI的理由很少,除非它是您唯一的选择。那么,没有理由使用IIS,除非您让它服务于应用程序所需的其他资产。谢谢,我也从这个问题开始。@Mossila欢迎您。我想这可能会帮助别人。很高兴这对你也有帮助。是的,我写这篇文章是在我为找到正确的方法而痛苦了一周之后!。哦,我不知道你是作者。我应该感谢你:)