有没有办法在 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 模块。
反向代理或 FastCGI 是较旧的方法,这种新方法不再需要。
我写了一篇包含示例和故障排除技巧的帖子来展示如何协同工作。
关于为什么你不应该使用ASP.NET Core模块,你可以在这里阅读历史记录。
HttpPlatformHandler 模块对我不起作用。我发现 Sutean Rutjanalard 在 Medium 上发表的这篇文章 非常有帮助,它使用 ASP.NET Core 模块来代替。
基本上,您需要像使用 .net core 应用程序一样创建“无托管代码”的应用程序池。以下是 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>