dou12352 2019-07-04 05:12
浏览 9

无法创建在线网页

I am trying to create Golang web-pages...

Progress:

  1. Ubuntu 18.04 installed both locally and on a Linode VPS.
  2. Created and compiled a local Golang "Hello World" script that renders OK both locally and online.
  3. Created a net/http Golang script that works OK when called locally http://localhost:8080/testing to see if it works
  4. Uploaded the script to the Linode server and initial status messages appear but when calling http:123.456.789.32:8080/testing to see if it works the browser freezes.
//
// Golang - main.go
//
package main

import (
  "net/http"
)

func sayHello(w http.ResponseWriter, r *http.Request) {
  message := r.URL.Path
  message = "Hello " + message

  w.Write([]byte(message))
}

func main() {
  http.HandleFunc("/", sayHello)

  if err := http.ListenAndServe(":8080", nil); err != nil {
    panic(err)
  }
}

There are no errors or warnings rendered and unable to find any log references.

Can error and warnings similar to PHP error_reporting(-1), declare(strict_types=1) etc be logged or rendered?

  • 写回答

1条回答 默认 最新

  • douchuo9476 2019-07-04 06:04
    关注

    A quick check with Nmap showed this result:

    nmap -sV -p 8080 <yourIP>
    Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-04 07:45 CEST
    Nmap scan report for <your-domain>.com (<yourIP>)
    Host is up (0.032s latency).
    
    PORT     STATE    SERVICE    VERSION
    8080/tcp filtered http-proxy
    
    Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    Nmap done: 1 IP address (1 host up) scanned in 0.90 seconds
    

    The state of "filtered" actually means that there was no response on that port as opposed to an outright rejection of the request.

    Check the output of iptables -L -n. Presumably, you have a firewall running and blocking port 8080. Do not simply deactivate the firewall, but read up on how to open port 8080 in the firewall product you are using. Linode has guides for the commonly used/preinstalled firewalls of various Linux distributions.

    If you plan to go into production, please have someone help you to ensure security and availability of your deployment.

    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助