Restringir o acesso a recursos a domínios específicos
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Para melhorar a segurança geral, o IAP, por padrão, nega o acesso a
solicitações que não têm uma indicação de nome do servidor (SNI) correspondente.
O IAP também verifica o SNI do certificado do balanceador de carga. Isso permite
que o IAP restrinja o redirecionamento de URL para domínios maliciosos. O
recurso de domínios permitidos do IAP oferece uma camada de segurança
extra para seus recursos protegidos pelo IAP. Como proprietário de recursos
ou administrador do IAP, você pode restringir o acesso a
recursos protegidos pelo IAP a domínios específicos ao configurar
o recurso de domínios permitidos.
Também é possível configurar domínios permitidos do IAP nos seguintes cenários:
Seu navegador ou um proxy intermediário está forçando o pool de conexões:nesse cenário, você recebe a resposta HTTP 429 e o código de erro 51. Para resolver o problema, um administrador do IAP pode atualizar a lista de domínios permitidos para incluir o nome do host.
O nome do host fornecido não corresponde ao certificado SSL no servidor:nesse cenário, você recebe o código de erro 52. Para resolver o problema, um administrador do IAP pode atualizar a lista de domínios permitidos para incluir o nome do host.
Configurar domínios permitidos
Use a gcloud ou a API para configurar as configurações de domínios permitidos. Para configurar os domínios permitidos, use os seguintes campos:
enable: booleano. Ativa ou desativa o recurso de domínios permitidos.
Domains: string. A lista de domínios permitidos. Os domínios podem ter prefixos de caractere curinga, como *.example.com.. Os nomes de domínio não podem ter um caractere curinga diretamente em um sufixo público ou em um domínio de nível superior. Exemplo: *.com, *.co.in.
RESOURCE_TYPE: o tipo de recurso do IAP. Precisa ser app-engine, iap_web, compute, organization ou folder.
SERVICE: o nome do serviço. Isso é opcional quando resource-type é compute ou app-engine.
VERSION: o nome da versão. Isso não é aplicável a compute e é opcional quando resource-type é app-engine.
API
Para configurar os domínios permitidos, siga estas etapas: Para mais informações sobre como usar a API para configurar domínios permitidos, consulte IapSettings.
Execute o comando a seguir para preparar um arquivo iap_settings.json. Atualize os valores conforme necessário.
Para conferir o nome do recurso, execute o comando gcloud iap settings get. Copie o campo de nome da saída. Você vai precisar do nome na próxima etapa.
gcloud iap settings get --organization=ORGANIZATION --folder=FOLDER --project=PROJECT --resource-type=RESOURCE_TYPE --service=SERVICE --version=VERSION
Substitua RESOURCE_NAME no comando a seguir pelo nome da etapa anterior. O IapSettings será atualizado.
Problema de acesso a domínios permitidos
Se você receber o código de erro 53, peça a um administrador do IAP para adicionar seu nome de host à lista de domínios permitidos.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 UTC."],[],[],null,["# Restrict resource access to specific domains\n\nTo improve overall security, IAP by default denies access to\nrequests that do not have a matching Server Name Indication (SNI).\nIAP also checks the SNI of the load balancer certificate. This allows\nIAP to restrict URL redirect to malicious domains. The\nIAP allowed domains feature provides an additional security\nlayer for your IAP-protected resources. As a resource owner\nor IAP administrator, you can restrict access to\nIAP-protected resources to specific domains by configuring\nthe allowed domains feature.\n\nYou can also configure IAP allowed domains in the following scenarios:\n\n- **Your browser or an intermediate proxy is forcing connection pooling:** In this scenario, you receive HTTP response 429 and error code [`51`](/iap/docs/faq?#error_codes). To resolve the issue, an IAP admin can update the list of allowed domains to include your host name.\n- **The host name provided does not match the SSL certificate on the server:** In this scenario, you receive error code [`52`](/iap/docs/faq?#error_codes). To resolve the issue, an IAP admin can update the list of allowed domains to include your host name.\n\nConfigure allowed domains\n-------------------------\n\nYou can use gcloud or the API to configure allowed domains settings. To configure allowed domains, use the following fields:\n\n- **`enable`**: Boolean. Turns the allowed domains feature on or off.\n- **`Domains`** : String. The list of allowed domains. The domains can contain wildcard prefixes, such as `*.example.com.` Domain names cannot contain a wildcard directly on a public suffix or on a top level domain. Example: `*.com`, `*.co.in`.\n\nFor more information, see [IapSettings](/iap/docs/reference/rest/v1/IapSettings#accesssettings).\n\nTo configure IAP allowed domains, complete the following steps: \n\n### Console\n\n1. Go to the IAP page. \n [Go to Identity-Aware Proxy](https://console.cloud.google.com/security/iap/).\n2. Select a project, and then select the resource on which you want to enable the allowed domains feature.\n3. Open **Settings** for the resource. Under **Allowed domains** , select **Enable Allowed Domains**.\n4. Specify the list of allowed domains, and then click **Save**.\n\n### gcloud\n\nFollowing are some example commands for specifying allowed domains.\n\nFor more information, see [`gcloud iap settings set`](/sdk/gcloud/reference/iap/settings/set).\n\nRun the following command: \n\n```\ngcloud iap settings set SETTING_FILE --folder=FOLDER --organization=ORGANIZATION --project=PROJECT --resource-type=RESOURCE_TYPE --service=SERVICE --version=VERSION\n```\n\nWhere `SETTING_FILE` is: \n\n accessSettings:\n allowed_domains_settings:\n enable: true\n domains: [\"*.example.com\", \"*.example.net\"]\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFOLDER\u003c/var\u003e: The folder ID.\n- \u003cvar translate=\"no\"\u003eORGANIZATION\u003c/var\u003e: The organization ID.\n- \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e: The project ID.\n- \u003cvar translate=\"no\"\u003eRESOURCE_TYPE\u003c/var\u003e: The IAP resource type. Must be `app-engine`, `iap_web`, `compute`, `organization`, or `folder`.\n- \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e: The service name. This is optional when `resource-type` is `compute` or `app-engine`.\n- \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e: The version name. This is not applicable for `compute`, and is optional when `resource-type` is `app-engine`.\n\n### API\n\nTo configure allowed domains, complete the following steps. For more information about using the API to configure allowed domains, see [IapSettings](/iap/docs/reference/rest/v1/IapSettings#accesssettings).\n\n1. Run the following command to prepare an `iap_settings.json` file. Update the values as needed.\n\n```\n {\n \"access_settings\":{\n \"allowed_domains_settings\":{\n \"enable\": true\n \"domains\": [\n \"*.example.com\",\n \"*.exampe.net\"\n ]\n }\n }\n }\n```\n\n1. Get the resource name by running the `gcloud iap settings get` command. Copy the name field from the output. You will need the name in the following step.\n\n```\ngcloud iap settings get --organization=ORGANIZATION --folder=FOLDER --project=PROJECT --resource-type=RESOURCE_TYPE --service=SERVICE --version=VERSION\n```\n\n1. Replace `RESOURCE_NAME` in the following command with the name from the previous step. The `IapSettings` will be updated.\n\n```\ncurl -X PATCH \\\n-H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n-H \"Accept: application/json\" \\\n-H \"Content-Type: application/json\" \\\n-d @iap_settings.json \\\n\"https://iap.googleapis.com/v1/RESOURCE_NAME:iapSettings?updateMask=iapSettings.accessSettings.allowedDomainsSettings.enable,iapSettings.accessSettings.allowedDomainsSettings.domains\"\n```\n\nTroubleshooting\n---------------\n\n**Allowed domains access issue** \n\nIf you receive [Error code 53](/iap/docs/faq?#error_codes), ask an IAP administrator to add your host name to the list of allowed domains."]]