我关注了一些youtube,也关注了stackoverflow thread,以在GCP中打开端口。防火墙规则已定义并绑定到我的VM,但无法从浏览器访问。
然后我检查了我的角度应用程序,该服务器还使用'ng serve'命令运行。
打开日志并进行记录
{
"insertId": "jzt0cnftr4835",
"jsonPayload": {
"connection": {
"dest_ip": "10.128.0.2",
"dest_port": 4201,
"src_port": 49222,
"protocol": 6,
"src_ip": "147.158.87.171"
},
"vpc": {
"vpc_name": "default",
"subnetwork_name": "default",
"project_id": "cloud-xp"
},
"disposition": "ALLOWED",
"remote_location": {
"city": "Johor Bahru",
"continent": "Asia",
"country": "mys",
"region": "Johor"
},
"rule_details": {
"direction": "INGRESS",
"action": "ALLOW",
"ip_port_info": [
{
"port_range": [
"4201"
],
"ip_protocol": "TCP"
}
],
"source_range": [
"0.0.0.0/0"
],
"priority": 1000,
"reference": "network:default/firewall:angular-apps"
},
"instance": {
"project_id": "cloud-xp",
"vm_name": "wordpress-1-vm",
"region": "us-central1",
"zone": "us-central1-f"
}
},
"resource": {
"type": "gce_subnetwork",
"labels": {
"project_id": "cloud-xp",
"subnetwork_id": "7656824026900524897",
"location": "us-central1-f",
"subnetwork_name": "default"
}
},
"timestamp": "2020-05-18T03:58:12.619210139Z",
"logName": "projects/cloud-xp/logs/compute.googleapis.com%2Ffirewall",
"receiveTimestamp": "2020-05-18T03:58:16.927671108Z"
}
Cloud Shell未在您的VPC中运行。创建防火墙规则对Cloud Shell无效。将您的应用程序的端口号更改为8080。