Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
## Application Gateway で HTTP --> HTTPS リダイレクト
$resourceGroupName = "リソースグループ名"
$appGwName = "Application Gateway 名"
$appGwFrontendIpName = "appGatewayFrontendIP"
$appgw = Get-AzureRmApplicationGateway -ResourceGroupName $resourceGroupName -Name $appGwName
# HTTP ポートの追加
Add-AzureRmApplicationGatewayFrontendPort -Name httpPort -Port 80 -ApplicationGateway $appgw
# HTTP リスナーの追加
$fipconfig = Get-AzureRmApplicationGatewayFrontendIPConfig -Name $appGwFrontendIpName -ApplicationGateway $appgw
$fp = Get-AzureRmApplicationGatewayFrontendPort -Name httpPort -ApplicationGateway $appgw
Add-AzureRmApplicationGatewayHttpListener -Name appGatewayHttpRedirectListener -Protocol Http -FrontendPort $fp -FrontendIPConfiguration $fipconfig -ApplicationGateway $appgw
# リダイレクト構成の追加
$defaultListener = Get-AzureRmApplicationGatewayHttpListener -Name appGatewayHttpListener -ApplicationGateway $appgw
Add-AzureRmApplicationGatewayRedirectConfiguration -Name httpToHttps -RedirectType Permanent -TargetListener $defaultListener -IncludePath $true -IncludeQueryString $true -ApplicationGateway $appgw
# ルーティング規則の追加
$myListener = Get-AzureRmApplicationGatewayHttpListener -Name appGatewayHttpRedirectListener -ApplicationGateway $appgw
$redirectConfig = Get-AzureRmApplicationGatewayRedirectConfiguration -Name httpToHttps -ApplicationGateway $appgw
Add-AzureRmApplicationGatewayRequestRoutingRule -Name rule2 -RuleType Basic -HttpListener $myListener -RedirectConfiguration $redirectConfig -ApplicationGateway $appgw
# 反映
Set-AzureRmApplicationGateway -ApplicationGateway $appgw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.