Azure App Service 'de TLS/SSL bağlaması ile özel bir DNS adının güvenliğini sağlamaSecure a custom DNS name with a TLS/SSL binding in Azure App Service
Bu makalede, bir sertifika bağlaması oluşturarak App Service uygulamanızda veya işlev uygulamanızda özel etki alanının güvenliğini sağlama işlemi gösterilmektedir.This article shows you how to secure the custom domain in your App Service app or function app by creating a certificate binding. İşiniz bittiğinde, https://
özel DNS adınızın uç noktasında App Service uygulamanıza erişebilirsiniz (örneğin, https://www.contoso.com
).When you're finished, you can access your App Service app at the https://
endpoint for your custom DNS name (for example, https://www.contoso.com
).
Özel bir etki alanını sertifikayla güvenli hale getirmek iki adımdan oluşur:Securing a custom domain with a certificate involves two steps:
- Tüm özel sertifika gereksinimlerinikarşılayan App Service özel bir sertifika ekleyin .Add a private certificate to App Service that satisfies all the private certificate requirements.
- Karşılık gelen özel etki alanına bir TLS bağlaması oluşturun.Create a TLS binding to the corresponding custom domain. Bu ikinci adım bu makalede ele alınmıştır.This second step is covered by this article.
Bu öğreticide şunların nasıl yapıldığını öğreneceksiniz:In this tutorial, you learn how to:
- Uygulamanızın fiyatlandırma katmanını yükseltmeUpgrade your app's pricing tier
- Özel bir etki alanını sertifikayla güvenli hale getirmeSecure a custom domain with a certificate
- HTTPS'yi zorunlu tutmaEnforce HTTPS
- TLS 1.1/1.2 zorlamaEnforce TLS 1.1/1.2
- TLS yönetimini betiklerle otomatikleştirmeAutomate TLS management with scripts
ÖnkoşullarPrerequisites
Bu nasıl yapılır kılavuzunu izlemek için:To follow this how-to guide:
- App Service uygulaması oluşturmaCreate an App Service app
- Uygulamanıza bir etki alanı adı eşleyin veya Azure 'da satın alıp yapılandırınMap a domain name to your app or buy and configure it in Azure
- Uygulamanıza özel bir sertifika ekleyinAdd a private certificate to your app
Not
Özel bir sertifika eklemenin en kolay yolu, ücretsiz App Service yönetilen bir sertifika oluşturmaktır (Önizleme).The easiest way to add a private certificate is to create a free App Service Managed Certificate (Preview).
Web uygulamanızı hazırlamaPrepare your web app
Özel TLS/SSL bağlamaları oluşturmak veya App Service uygulamanız için istemci sertifikalarını etkinleştirmek üzere App Service planınız temel, Standart, Premium veya yalıtılmış katmanda olmalıdır.To create custom TLS/SSL bindings or enable client certificates for your App Service app, your App Service plan must be in the Basic, Standard, Premium, or Isolated tier. Bu adımda, web uygulamanızın desteklenen bir fiyatlandırma katmanında olduğundan emin olacaksınız.In this step, you make sure that your web app is in the supported pricing tier.
Azure'da oturum açmaSign in to Azure
Azure portalını açın.Open the Azure portal.
Web uygulamanıza gidinNavigate to your web app
Uygulama hizmetleri' ni arayıp seçin.Search for and select App Services.
Uygulama hizmetleri sayfasında, Web uygulamanızın adını seçin.On the App Services page, select the name of your web app.
Web uygulamanızın yönetim sayfasına ulaştınız.You have landed on the management page of your web app.
Fiyatlandırma katmanını denetlemeCheck the pricing tier
Web uygulaması sayfasının sol gezinti bölmesinde Ayarlar bölümüne kaydırın ve Ölçeği artır (App Service planı) öğesini seçin.In the left-hand navigation of your web app page, scroll to the Settings section and select Scale up (App Service plan).
Web uygulamanızın F1 veya D1 katmanında olmadığından emin olun.Check to make sure that your web app is not in the F1 or D1 tier. Web uygulamanızın geçerli katmanı koyu mavi bir kutuyla vurgulanır.Your web app's current tier is highlighted by a dark blue box.
F1 veya D1 katmanında özel SSL desteklenmez.Custom SSL is not supported in the F1 or D1 tier. Ölçeği artırmanız gerekirse sonraki bölümde verilen adımları izleyin.If you need to scale up, follow the steps in the next section. Aksi takdirde, Ölçek artırma sayfasını kapatın ve App Service planınızı ölçeği büyütme bölümünü atlayın.Otherwise, close the Scale up page and skip the Scale up your App Service plan section.
App Service planınızın ölçeğini artırmaScale up your App Service plan
Ücretsiz olmayan katmanlardan birini seçin (B1, B2, B3, veya Üretim kategorisindeki herhangi bir katmanı).Select any of the non-free tiers (B1, B2, B3, or any tier in the Production category). Ek seçenekler için Ek seçeneklere bakın’a tıklayın.For additional options, click See additional options.
Uygula’ya tıklayın.Click Apply.
Aşağıdaki bildirimi gördüğünüzde, ölçeklendirme işlemi tamamlanmıştır.When you see the following notification, the scale operation is complete.
Özel bir etki alanının güvenliğini sağlamaSecure a custom domain
Aşağıdaki adımları uygulayın:Do the following steps:
Azure Portal, sol menüden uygulama hizmetleri' ni seçin > <app-name> .In the Azure portal, from the left menu, select App Services > <app-name>.
Uygulamanızın sol gezinti bölmesinde, TLS/SSL bağlama iletişim kutusunu şu şekilde başlatın:From the left navigation of your app, start the TLS/SSL Binding dialog by:
- Özel etki alanlarını seçme > bağlama eklemeSelecting Custom domains > Add binding
- TLS/ SSL ayarlarını seçme > TLS/SSL bağlaması EkleSelecting TLS/SSL settings > Add TLS/SSL binding
Özel etki alanı' nda, bir bağlama eklemek istediğiniz özel etki alanını seçin.In Custom Domain, select the custom domain you want to add a binding for.
Uygulamanızda zaten seçili özel etki alanı için bir sertifika varsa doğrudan bağlama oluştur ' a gidin.If your app already has a certificate for the selected custom domain, go to Create binding directly. Aksi takdirde, devam edin.Otherwise, keep going.
Özel etki alanı için sertifika eklemeAdd a certificate for custom domain
Uygulamanızda seçili özel etki alanı için sertifika yoksa, iki seçeneğiniz vardır:If your app has no certificate for the selected custom domain, then you have two options:
- PFX sertifikasını karşıya yükleme - özel bir sertifikayı karşıya yüklemesırasında iş akışını izleyin ve burada bu seçeneği belirleyin.Upload PFX Certificate - Follow the workflow at Upload a private certificate, then select this option here.
- Içeri aktarma App Service sertifikası - App Service sertifikasını içeri aktarmasırasında iş akışını izleyin ve burada bu seçeneği belirleyin.Import App Service Certificate - Follow the workflow at Import an App Service certificate, then select this option here.
Not
Ayrıca, ücretsiz bir sertifika (Önizleme) oluşturabilir veya bir Key Vault sertifikasını içeri aktarabilirsiniz, ancak bunu ayrı olarak yapmanız ve sonra TLS/SSL bağlama iletişim kutusuna geri dönmeniz gerekir.You can also Create a free certificate (Preview) or Import a Key Vault certificate, but you must do it separately and then return to the TLS/SSL Binding dialog.
Bağlama oluşturCreate binding
TLS /SSL bağlama ILETIŞIM kutusunda TLS bağlamasını yapılandırmanıza yardımcı olması için aşağıdaki tabloyu kullanın, sonra bağlama Ekle' ye tıklayın.Use the following table to help you configure the TLS binding in the TLS/SSL Binding dialog, then click Add Binding.
AyarSetting | AçıklamaDescription |
---|---|
Özel etki alanıCustom domain | İçin TLS/SSL bağlamasını eklemek için etki alanı adı.The domain name to add the TLS/SSL binding for. |
Özel sertifika parmak IziPrivate Certificate Thumbprint | Bağlanacak sertifika.The certificate to bind. |
TLS/SSL türüTLS/SSL Type |
|
İşlem tamamlandıktan sonra, özel etki alanının TLS/SSL durumu güvenli olarak değiştirilir.Once the operation is complete, the custom domain's TLS/SSL state is changed to Secure.
Not
Özel etki alanlarında güvenli bir durum, bir sertifikayla güvenli hale getirildiği anlamına gelir, App Service ancak örneğin, tarayıcının otomatik olarak imzalanıp imzalanmadığını veya dolduğunu (örneğin, tarayıcıların bir hata veya uyarı görüntülemesine da neden olabilir) kontrol etmez.A Secure state in the Custom domains means that it is secured with a certificate, but App Service doesn't check if the certificate is self-signed or expired, for example, which can also cause browsers to show an error or warning.
IP SSL için kayıtları yeniden eşleyinRemap records for IP SSL
Uygulamanızda IP SSL kullanmıyorsanız, özel etki alanınız Için test https'ye atlayın.If you don't use IP SSL in your app, skip to Test HTTPS for your custom domain.
Yapmanız gereken iki değişiklik olabilir:There are two changes you need to make, potentially:
Varsayılan olarak, uygulamanız paylaşılan bir genel IP adresi kullanır.By default, your app uses a shared public IP address. Bir sertifikayı IP SSL bağladığınızda App Service, uygulamanız için yeni ve ayrılmış bir IP adresi oluşturur.When you bind a certificate with IP SSL, App Service creates a new, dedicated IP address for your app. Bir kaydı uygulamanızla eşleştirdiyseniz, etki alanı kayıt defterinizi bu yeni, ayrılmış IP adresiyle güncelleştirin.If you mapped an A record to your app, update your domain registry with this new, dedicated IP address.
Uygulamanızın özel etki alanı sayfası, yeni ve ayrılmış IP adresi ile güncelleştirilir.Your app's Custom domain page is updated with the new, dedicated IP address. Bu IP adresini kopyalayın, ardından bu yeni IP adresine A kaydını yeniden eşleyin.Copy this IP address, then remap the A record to this new IP address.
' A bir SNI SSL bağlamanız varsa
<app-name>.azurewebsites.net
, HERHANGI bir CNAME eşlemesinisni.<app-name>.azurewebsites.net
(öneki ekleyin) işaret etmek için yeniden eşleyinsni
.If you have an SNI SSL binding to<app-name>.azurewebsites.net
, remap any CNAME mapping to point tosni.<app-name>.azurewebsites.net
instead (add thesni
prefix).
HTTPS’yi test etmeTest HTTPS
Çeşitli tarayıcılarda, https://<your.custom.domain>
uygulamanızı hizmet ettiğini doğrulamak için öğesine gidin.In various browsers, browse to https://<your.custom.domain>
to verify that it serves up your app.
Uygulama kodunuz, "x-appservice-proto" üst bilgisi aracılığıyla Protokolü inceleyebilir.Your application code can inspect the protocol via the "x-appservice-proto" header. Üst bilgi, veya değerine sahip olacaktır http
https
.The header will have a value of http
or https
.
Not
Uygulamanız size sertifika doğrulama hataları veriyorsa, muhtemelen kendinden imzalı bir sertifika kullanıyorsunuz demektir.If your app gives you certificate validation errors, you're probably using a self-signed certificate.
Böyle bir durum söz konusu değilse, sertifikanızı PFX dosyasına aktardığınızda ara sertifikaları dışarıda bırakmış olabilirsiniz.If that's not the case, you may have left out intermediate certificates when you export your certificate to the PFX file.
IP değişikliklerini engellePrevent IP changes
Bağlama IP SSL olsa bile, bir bağlamayı sildiğinizde gelen IP adresiniz değişebilir.Your inbound IP address can change when you delete a binding, even if that binding is IP SSL. Bu, daha önce IP SSL bağlamasındaki bir sertifikayı yenileçalıştığınızda özellikle önemlidir.This is especially important when you renew a certificate that's already in an IP SSL binding. Uygulamanızın IP adresinin değişmesini önlemek için şu adımları sırasıyla izleyin:To avoid a change in your app's IP address, follow these steps in order:
- Yeni sertifikayı karşıya yükleyin.Upload the new certificate.
- Eskisini silmeden yeni sertifikayı istediğiniz özel etki alanına bağlayın.Bind the new certificate to the custom domain you want without deleting the old one. Bu eylem, eskisini kaldırmak yerine bağlamayı değiştirir.This action replaces the binding instead of removing the old one.
- Eski sertifikayı silin.Delete the old certificate.
HTTPS'yi zorunlu tutmaEnforce HTTPS
Varsayılan olarak, herhangi biri HTTP kullanarak uygulamanıza erişmeye devam edebilir.By default, anyone can still access your app using HTTP. Tüm HTTPS isteklerini HTTP bağlantı noktasına yeniden yönlendirebilirsiniz.You can redirect all HTTP requests to the HTTPS port.
Uygulama sayfanızda, sol gezinti bölmesinde SSL ayarları' nı seçin.In your app page, in the left navigation, select SSL settings. Ardından Yalnızca HTTPS menüsünde Açık’ı seçin.Then, in HTTPS Only, select On.
İşlem tamamlandığında, uygulamanıza işaret eden HTTP URL'lerinden herhangi birine gidin.When the operation is complete, navigate to any of the HTTP URLs that point to your app. Örnek:For example:
http://<app_name>.azurewebsites.net
http://contoso.com
http://www.contoso.com
TLS sürümlerini zorlamaEnforce TLS versions
Uygulamanız varsayılan olarak TLS 1.2 sürümüne izin verir. Bu, PCI DSS gibi endüstri standartlarınca önerilen TLS düzeyidir.Your app allows TLS 1.2 by default, which is the recommended TLS level by industry standards, such as PCI DSS. Farklı TLS sürümlerini zorlamak için aşağıdaki adımları uygulayın:To enforce different TLS versions, follow these steps:
Uygulama sayfanızda, sol gezinti bölmesinde SSL ayarları' nı seçin.In your app page, in the left navigation, select SSL settings. Ardından TLS sürümü’nde istediğiniz en düşük TLS sürümünü seçin.Then, in TLS version, select the minimum TLS version you want. Bu ayar yalnızca gelen çağrıları denetler.This setting controls the inbound calls only.
İşlem tamamlandığında, uygulamanız daha düşük TLS sürümleriyle tüm bağlantıları reddeder.When the operation is complete, your app rejects all connections with lower TLS versions.
TLS sonlandırmayı işleHandle TLS termination
App Service, ağ yükü dengeleyicilerde TLS sonlandırması olur, bu nedenle tüm https istekleri UYGULAMANıZA şifrelenmemiş HTTP istekleri olarak ulaşacak.In App Service, TLS termination happens at the network load balancers, so all HTTPS requests reach your app as unencrypted HTTP requests. Uygulama mantığınızın kullanıcı isteklerinin şifrelenip şifrelenmediğini denetlemesi gerekiyorsa, X-Forwarded-Proto
üstbilgiyi inceleyin.If your app logic needs to check if the user requests are encrypted or not, inspect the X-Forwarded-Proto
header.
Linux Node.js yapılandırma kılavuzu gibi dile özgü yapılandırma kılavuzlarında, uygulama KODUNUZDA bir https oturumunun nasıl algılanacağı gösterilir.Language specific configuration guides, such as the Linux Node.js configuration guide, shows you how to detect an HTTPS session in your application code.
Betiklerle otomatikleştirmeAutomate with scripts
Azure CLIAzure CLI
#!/bin/bash
fqdn=<replace-with-www.{yourdomain}>
pfxPath=<replace-with-path-to-your-.PFX-file>
pfxPassword=<replace-with-your=.PFX-password>
resourceGroup=myResourceGroup
webappname=mywebapp$RANDOM
# Create a resource group.
az group create --location westeurope --name $resourceGroup
# Create an App Service plan in Basic tier (minimum required by custom domains).
az appservice plan create --name $webappname --resource-group $resourceGroup --sku B1
# Create a web app.
az webapp create --name $webappname --resource-group $resourceGroup \
--plan $webappname
echo "Configure a CNAME record that maps $fqdn to $webappname.azurewebsites.net"
read -p "Press [Enter] key when ready ..."
# Before continuing, go to your DNS configuration UI for your custom domain and follow the
# instructions at https://aka.ms/appservicecustomdns to configure a CNAME record for the
# hostname "www" and point it your web app's default domain name.
# Map your prepared custom domain name to the web app.
az webapp config hostname add --webapp-name $webappname --resource-group $resourceGroup \
--hostname $fqdn
# Upload the SSL certificate and get the thumbprint.
thumbprint=$(az webapp config ssl upload --certificate-file $pfxPath \
--certificate-password $pfxPassword --name $webappname --resource-group $resourceGroup \
--query thumbprint --output tsv)
# Binds the uploaded SSL certificate to the web app.
az webapp config ssl bind --certificate-thumbprint $thumbprint --ssl-type SNI \
--name $webappname --resource-group $resourceGroup
echo "You can now browse to https://$fqdn"
PowerShellPowerShell
$fqdn="<Replace with your custom domain name>"
$pfxPath="<Replace with path to your .PFX file>"
$pfxPassword="<Replace with your .PFX password>"
$webappname="mywebapp$(Get-Random)"
$location="West Europe"
# Create a resource group.
New-AzResourceGroup -Name $webappname -Location $location
# Create an App Service plan in Free tier.
New-AzAppServicePlan -Name $webappname -Location $location `
-ResourceGroupName $webappname -Tier Free
# Create a web app.
New-AzWebApp -Name $webappname -Location $location -AppServicePlan $webappname `
-ResourceGroupName $webappname
Write-Host "Configure a CNAME record that maps $fqdn to $webappname.azurewebsites.net"
Read-Host "Press [Enter] key when ready ..."
# Before continuing, go to your DNS configuration UI for your custom domain and follow the
# instructions at https://aka.ms/appservicecustomdns to configure a CNAME record for the
# hostname "www" and point it your web app's default domain name.
# Upgrade App Service plan to Basic tier (minimum required by custom SSL certificates)
Set-AzAppServicePlan -Name $webappname -ResourceGroupName $webappname `
-Tier Basic
# Add a custom domain name to the web app.
Set-AzWebApp -Name $webappname -ResourceGroupName $webappname `
-HostNames @($fqdn,"$webappname.azurewebsites.net")
# Upload and bind the SSL certificate to the web app.
New-AzWebAppSSLBinding -WebAppName $webappname -ResourceGroupName $webappname -Name $fqdn `
-CertificateFilePath $pfxPath -CertificatePassword $pfxPassword -SslState SniEnabled