我正在尝试从我的ios应用项目连接到Google云实例。但我坚持连接到谷歌云。看过这个教程但是已经过时了。 https://www.youtube.com/watch?v=gxZvofAvgHQ&t=179s
以下是我将在我的应用中使用的代码
Alamofire.request("http://external_ip:80/test.php", method: .post, parameters: ["test": String(1)]).responseString { (response) in
switch response.result {
case .success(let data):
print(response.result)
case .failure(let error):
print(error)
}
}
尝试连接到Google云端的步骤。
Failed to open page
gcloud beta compute firewall-rules list
NAME NETWORK DIRECTION PRIORITY ALLOW DENY
default-allow-http default INGRESS 1000 tcp:80
default-allow-https default INGRESS 1000 tcp:443
default-allow-icmp default INGRESS 65534 icmp
default-allow-internal default INGRESS 65534 tcp:0-65535,udp:065535,icmp
default-allow-rdp default INGRESS 65534 tcp:3389
default-allow-ssh default INGRESS 65534 tcp:22
rule-allow-tcp-80 default INGRESS 1000 tcp:80
gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
outbuy asia-east1-a f1-micro internal_ip external_ip RUNNING
gcloud compute ssh <my_pj>
然后sudo nc -l -vv -p 80
nc:listen:地址已在使用中
添加了这个
// On your workstation:
SUBNETWORK_URI=$(gcloud compute instances describe ${COS_INSTANCE_NAME} | grep -w 'subnetwork:' | awk '{ print $2 }')
SUBNET_PREFIX=$(gcloud compute networks subnets describe ${SUBNETWORK_URI} | grep -w 'ipCidrRange:' | awk '{ print $2 }')
// On your Container-Optimized OS instance:
sudo iptables -w -A INPUT -p tcp -s ${SUBNET_PREFIX} -j ACCEPT
sudo iptables -w -A INPUT -p udp -s ${SUBNET_PREFIX} -j ACCEPT
并且
// Add a new tag based firewall rule to allow ingress tcp:80
gcloud compute firewall-rules create rule-allow-tcp-80 --source-ranges 0.0.0.0/0 --target-tags allow-tcp-80 --allow tcp:80
// Add the allow-tcp-80 target tag to the VM ssrf3
gcloud compute instances add-tags ssrf3 --tags allow-tcp-80
仍然没有变化。
有什么建议吗?