Menggunakan konektivitas IP pribadi sumber dengan reverse proxy

Halaman ini menjelaskan cara menyiapkan reverse proxy di Virtual Machine (VM) Compute Engine untuk memfasilitasi konektivitas pribadi sumber untuk migrasi Oracle heterogen.

VM reverse proxy diperlukan jika Anda ingin menggunakan konektivitas IP pribadi dengan sumber yang berada di jaringan Virtual Private Cloud yang berbeda dengan jaringan tempat Anda membuat konfigurasi konektivitas pribadi.

Menyiapkan reverse proxy

Untuk membuat VM Compute Engine guna menghosting proxy, ikuti langkah-langkah berikut:

  1. Buat instance VM Linux di Compute Engine.
  2. Setelah terhubung ke mesin, buat perutean iptables yang diperlukan untuk meneruskan traffic. Anda dapat menggunakan skrip berikut.

    Sebelum menggunakan salah satu data perintah di bawah, lakukan penggantian berikut:

    • SOURCE_PRIVATE_IP dengan alamat IP pribadi instance sumber Anda.
    • PORT dengan nomor port tempat instance Oracle sumber Anda memproses koneksi.
    #! /bin/bash
    
    export DB_ADDR=SOURCE_PRIVATE_IP
    export DB_PORT=DATABASE_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

    VM proxy Anda sekarang berjalan. Lanjutkan dengan langkah-langkah lainnya yang diperlukan untuk konektivitas sumber Anda.

Langkah berikutnya