Usar a conectividade de IP particular de origem com um proxy reverso

Esta página explica como configurar um proxy reverso em uma máquina virtual (VM) do Compute Engine para facilitar a conectividade privada de origem em migrações heterogêneas do Oracle.

Uma VM de proxy reverso é necessária quando você quer usar conectividade de IP particular com uma origem que reside em uma rede de nuvem privada virtual diferente daquela em que você cria uma configuração de conectividade particular para peering de VPC.

Configurar um proxy reverso

Para criar uma VM do Compute Engine para hospedar o proxy, siga estas etapas:

  1. Crie uma instância de VM do Linux no Compute Engine.
  2. Depois de se conectar à máquina, crie o roteamento iptables necessário para encaminhar o tráfego. Use o script a seguir.

    Antes de usar os dados do comando abaixo, faça estas substituições:

    • SOURCE_PRIVATE_IP pelo endereço IP privado da instância de origem.
    • PORT com o número da porta em que a instância de origem do Oracle está detectando conexões.
    #! /bin/bash
    
    export DB_ADDR=SOURCE_PRIVATE_IP
    export DB_PORT=PORT
    
    # Enable the VM to receive packets whose destinations do
    # not match any running process local to the VM
    echo 1 > /proc/sys/net/ipv4/ip_forward
    
    # Ask the Metadata server for the IP address of the VM nic0
    # network interface:
    md_url_prefix="http://169.254.169.254/computeMetadata/v1/instance"
    vm_nic_ip="$(curl -H "Metadata-Flavor: Google" ${md_url_prefix}/network-interfaces/0/ip)"
    
    # Clear any existing iptables NAT table entries (all chains):
    iptables -t nat -F
    
    # Create a NAT table entry in the prerouting chain, matching
    # any packets with destination database port, changing the destination
    # IP address of the packet to your source instance IP address:
    iptables -t nat -A PREROUTING \
         -p tcp --dport $DB_PORT \
         -j DNAT \
         --to-destination $DB_ADDR
    
    # Create a NAT table entry in the postrouting chain, matching
    # any packets with destination database port, changing the source IP
    # address of the packet to the NAT VM's primary internal IPv4 address:
    iptables -t nat -A POSTROUTING \
         -p tcp --dport $DB_PORT \
         -j SNAT \
         --to-source $vm_nic_ip
    
    # Save iptables configuration:
    iptables-save

    Sua VM de proxy está em execução. Siga as etapas restantes necessárias para a conectividade da sua origem.

A seguir