doufeng5059 2016-01-28 06:48
浏览 39

gcloud计算:为外部流量配置防火墙

I am attempting to configure my google cloud instance to allow external traffic so I can set up a web socket; however despite adding a rule for all external TCP/IP traffic, I can't access it. My rules are:

gcloud compute firewall-rules list
NAME              NETWORK SRC_RANGES RULES   SRC_TAGS TARGET_TAGS
default-allow-ssh default 0.0.0.0/0  tcp:22
external-traffic  default 0.0.0.0/0  tcp,udp


gcloud compute instances list
NAME      ZONE          MACHINE_TYPE  PREEMPTIBLE INTERNAL_IP EXTERNAL_IP    STATUS
pi-server us-central1-a n1-standard-1             **.***.*.*  **.***.***.*** RUNNING

I have configured this as a static IP (this is displayed in my cloud dashboard):

Name               External Address Region      Type    In use by
crypto-iris-******  **.***.***.***  us-central1 Static  VM instance my_instance_name (Zone a)   

I also have some Go client/server web socket code that works perfectly on my computer using localhost:8080 as address. So, my question is: can I simply replace localhost with the external static IP of my instance under these rules?

My client makes use of "github.com/gorilla/websocket" on port 8080. Output of client locally is:

connecting to ws://23.251.148.133:8080/echo
dial:dial tcp 23.251.148.133:8080: getsockopt: operation timed out
exit status 1

Code upon request, if anyone wants to see it.

  • 写回答

1条回答 默认 最新

  • doujiu7704 2016-01-28 23:43
    关注

    Problem: my golang/gorilla server was hosting on localhost:8080. I changed it to 0.0.0.0:8080. Smooth sailing after that.

    See following post about this, but basically the server was listening to the local loopback address (available only to local machine) instead of the outside world.

    https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法