Ir para o conteúdo
NimbusNexus

Grupos de segurança

Grupos de segurança são conjuntos de regras de firewall stateful. Você anexa um ou mais grupos à interface de rede de uma VM; o que é aplicado é a união das regras de todos os grupos. Comportamento padrão: negar todo o tráfego de entrada, permitir todo o tráfego de saída — allow-list explícita para o tráfego que chega, saída liberada até você dizer o contrário.

O que significa stateful

Você só escreve regras para a direção que inicia a conexão. Se você permite TCP de entrada na porta 443, os pacotes de resposta ao cliente são permitidos automaticamente — não é preciso uma regra de egress separada para o tráfego de retorno.

Compare com uma ACL stateless (por exemplo, as Network ACLs da AWS), em que você precisaria de regras simétricas nas duas direções. Os grupos de segurança são mais fáceis de entender para firewall no nível da aplicação; as ACLs stateless são mais fáceis de entender para políticas de rede de tenant em uma camada abaixo da VM.

Formato da regra

Cada regra tem:

  • Direção — ingress ou egress
  • Tipo Ether — ether: IPv4 ou IPv6
  • Protocolo — any, um nome como tcp, udp, icmp, ipv6-icmp ou sctp, ou custom com um número de protocolo (0–255) em protocol_custom
  • Intervalo de portas — port_min e port_max, cada um entre 0 e 65535. Informe só port_min para uma porta única (80), os dois para um intervalo (8000 a 9000) ou nenhum para qualquer porta
  • Origem / destino — um bloco CIDR em remote_cidr (0.0.0.0/0, 10.0.0.0/8), outro grupo de segurança em remote_sec_grp ou um grupo de endereços em remote_addr_grp

O modo "a origem é outro grupo de segurança" é o que mais vale a pena conhecer. Uma regra como "permitir a porta 5432 a partir de web-tier-sg" deixa toda VM do grupo web-tier-sg acessar sua VM de Postgres na 5432 — sem precisar enumerar IPs, e a regra continua funcionando conforme as VMs entram e saem do web-tier-sg com o escalonamento.

Um padrão comum

Para um app web de 3 camadas:

  1. web-tier-sg — entrada: permitir tcp/80 e tcp/443 a partir de 0.0.0.0/0 (público)
  2. app-tier-sg — entrada: permitir tcp/8080 a partir de web-tier-sg (só a camada web consegue acessar a camada de app)
  3. db-tier-sg — entrada: permitir tcp/5432 a partir de app-tier-sg (só a camada de app consegue acessar o banco de dados)

Isso se combina; você pode adicionar um 4º grupo para uma VPN de operações que permite SSH a partir dos IPs do seu escritório e anexá-lo junto com o db-tier-sg nas VMs de banco de dados, sem mexer nas regras do app.

Próximos passos

Reference

GET/api/v1/security_group/

Groups List

Lists security groups visible to the project, including their rules.

Parameters

NameInTypeDescription
admin_domainquerystring | null—
admin_projectquerystring | null—
projectquerystring | null—

Responses

  • 200Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X GET "https://api.nimbusnexus.net/api/v1/security_group/" \
  -H "Authorization: Bearer $NIMBUS_KEY"
POST/api/v1/security_group/

Group Create

Creates a new security group in the scoped project.

Request body

FieldTypeDescription
admin_domainstring | null—
admin_projectstring | null—
projectstring | null—
name*string—
descriptionstring | null—

Responses

  • 201Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X POST "https://api.nimbusnexus.net/api/v1/security_group/" \
  -H "Authorization: Bearer $NIMBUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example"
  }'
DELETE/api/v1/security_group/

Group Delete

Deletes a security group, rejecting the request when it is still in use.

Request body

FieldTypeDescription
id*string—

Responses

  • 204Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X DELETE "https://api.nimbusnexus.net/api/v1/security_group/" \
  -H "Authorization: Bearer $NIMBUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "example"
  }'
GET/api/v1/security_group/instance

Instance Groups List

Lists security groups annotated with whether they are linked to a given instance.

Parameters

NameInTypeDescription
admin_domainquerystring | null—
admin_projectquerystring | null—
projectquerystring | null—
id*querystring—
show_allqueryboolean—

Responses

  • 200Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X GET "https://api.nimbusnexus.net/api/v1/security_group/instance?id=example" \
  -H "Authorization: Bearer $NIMBUS_KEY"
PUT/api/v1/security_group/instance

Instance Groups Update

Synchronizes an instance attached security groups with the supplied desired set.

Request body

FieldTypeDescription
instance_id*string—
desired_group_ids*array of string—

Responses

  • 200Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X PUT "https://api.nimbusnexus.net/api/v1/security_group/instance" \
  -H "Authorization: Bearer $NIMBUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "instance_id": "<instance_id>",
    "desired_group_ids": [
      "<desired_group_id>"
    ]
  }'
POST/api/v1/security_group/rule

Rule Create

Adds an ingress or egress rule to an existing security group.

Request body

FieldTypeDescription
security_group_id*string—
direction*Directions—
ether*Ethers—
protocol*integer | Protocols—
protocol_custominteger | string | null—
port_mininteger | null—
port_maxinteger | null—
icmp_typeinteger | null—
icmp_codeinteger | null—
remote_cidrstring | null—
remote_sec_grpstring | null—
remote_addr_grpstring | null—
descriptionstring | null—

Responses

  • 201Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X POST "https://api.nimbusnexus.net/api/v1/security_group/rule" \
  -H "Authorization: Bearer $NIMBUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "security_group_id": "<security_group_id>",
    "direction": "ingress",
    "ether": "IPv4",
    "protocol": 1
  }'
DELETE/api/v1/security_group/rule/delete

Rule Delete

Deletes one or more security group rules by ID.

Request body

FieldTypeDescription
ids*array of string—

Responses

  • 204Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X DELETE "https://api.nimbusnexus.net/api/v1/security_group/rule/delete" \
  -H "Authorization: Bearer $NIMBUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "example"
    ]
  }'
PUT/api/v1/security_group/{security_group_id}

Group Update

Updates a security group in the scoped project.

Parameters

NameInTypeDescription
security_group_id*pathstring—

Request body

FieldTypeDescription
namestring | null—
descriptionstring | null—

Responses

  • 200Successful Response
  • 400Bad Request
  • 401Unauthorized
  • 403Forbidden
  • 404Not Found
  • 409Conflict
  • 422Validation Error
  • 429Too Many Requests
  • 500Internal Server Error

Example

curl -X PUT "https://api.nimbusnexus.net/api/v1/security_group/<security_group_id>" \
  -H "Authorization: Bearer $NIMBUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Need to make a real call? Try these endpoints in the live Swagger UI →