gpt4 book ai didi

powershell - Octopus Deploy - 用于在 IIS 上设置 SSL 绑定(bind)的 Deploy.ps1 脚本

转载 作者:行者123 更新时间:2023-12-04 13:52:15 31 4
gpt4 key购买 nike

使用 Octopus 部署脚本创建网站找到 here

我正在尝试建立一个使用 SSL 的网站。我已更改 http -> https并且变量设置为此$MyWebAppIisBindings = "*:433:"
除了设置证书之外,此脚本会执行所有操作来创建新站点并部署我的应用程序。

我有一份名为 'webserver' 的证书可以从 IIS 7 管理器的编辑站点绑定(bind)对话框的组合框中选择。手动选择此项可使 SSL 按预期工作。

什么Powershell cmdlet我是否需要添加到部署脚本才能将我的证书与我在 IIS 上的绑定(bind)相关联?

(我是一个完整的 Powershell 菜鸟,请不要假设我在您的回答中对此一无所知)

编辑:我进步了一点,但我还是迷路了

# think I need to do something like this to get the certificate 
# Get-Item cert:\LocalMachine\My\$siteCertThumb
# but I have no idea how to assign it to the 443 binding

最佳答案

为了扩展 Jared 的答案,这里有一个来自最近使用 HTTP 和 HTTPS 的项目的完整脚本:

#
# Settings
#---------------
$appPoolName = ("Kraken-Pool-" + $OctopusEnvironmentName)
$siteName = ("Kraken - " + $OctopusEnvironmentName)
$siteBindings = ":80:octopushq.com"
$siteBindingsSecure = ":443:octopushq.com"
$siteCertificate = "CERT:\LocalMachine\WebHosting\A347FC4B77A2C176E451D8CE4973C7D0FB3E19AA"
$appPoolFrameworkVersion = "v4.0"
$webRoot = (resolve-path .)

# Installation
#---------------
Import-Module WebAdministration

cd IIS:\

$appPoolPath = ("IIS:\AppPools\" + $appPoolName)
$pool = Get-Item $appPoolPath -ErrorAction SilentlyContinue
if (!$pool) {
Write-Host "App pool does not exist, creating..."
new-item $appPoolPath
$pool = Get-Item $appPoolPath
} else {
Write-Host "App pool exists."
}

Write-Host "Set .NET framework version:" $appPoolFrameworkVersion
Set-ItemProperty $appPoolPath managedRuntimeVersion $appPoolFrameworkVersion

Write-Host "Set identity..."
Set-ItemProperty $appPoolPath -name processModel -value @{identitytype="NetworkService"}

Write-Host "Checking site..."
$sitePath = ("IIS:\Sites\" + $siteName)
$site = Get-Item $sitePath -ErrorAction SilentlyContinue
if (!$site) {
Write-Host "Site does not exist, creating..."
$id = (dir iis:\sites | foreach {$_.id} | sort -Descending | select -first 1) + 1
new-item $sitePath -bindings @{protocol="http";bindingInformation=$siteBindings} -id $id -physicalPath $webRoot
} else {
Write-Host "Site exists. Complete"
}

Write-Host "Set app pool..."
Set-ItemProperty $sitePath -name applicationPool -value $appPoolName

Write-Host "Set bindings..."
Set-ItemProperty $sitePath -name bindings -value @{protocol="http";bindingInformation=$siteBindings}
New-ItemProperty $sitePath -name bindings -value @{protocol="https";bindingInformation=$siteBindingsSecure}
Get-Item $siteCertificate | Set-Item IIS://SslBindings/0.0.0.0!443

Write-Host "Set path..."
Set-ItemProperty $sitePath -name physicalPath -value "$webRoot"

Write-Host "IIS configuration complete!"

关于powershell - Octopus Deploy - 用于在 IIS 上设置 SSL 绑定(bind)的 Deploy.ps1 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14313296/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com