V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
missdeer
V2EX  ›  分享创造

因为嫌 ifconfig.me 太慢,所以花了大半天时间在京东云上部署了个类似的 http://ifconfig.jd-app.com

  •  1
     
  •   missdeer · 2014 年 8 月 15 日 · 5861 次点击
    这是一个创建于 4182 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2014 年 8 月 15 日
    我收罗过一些获取出口IP的方法,但哪有自己搞的心里爽啊!
    external_addr=$(dig +short myip.opendns.com @resolver1.opendns.com)
    external_addr=$(curl http://ifconfig.me 2> /dev/null )
    external_addr=$(curl ip.appspot.com)
    external_addr=$(curl icanhazip.com)
    external_addr=$(curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+")
    17 条回复    2014-08-16 03:31:24 +08:00
    hcymk2
        1
    hcymk2  
       2014 年 8 月 15 日
    好像是直接用bee弄的吧。
    qiuai
        2
    qiuai  
    PRO
       2014 年 8 月 15 日
    确实不错.不过为啥不弄个顶级域名...
    missdeer
        3
    missdeer  
    OP
       2014 年 8 月 15 日
    @hcymk2 是的。

    @qiuai 要备案,没心思陪他们玩。
    jwk345
        4
    jwk345  
       2014 年 8 月 15 日
    binux
        5
    binux  
       2014 年 8 月 15 日
    qiuai
        6
    qiuai  
    PRO
       2014 年 8 月 15 日
    @missdeer =.=...我倒是有香港的机器,但是没太明白你这个环境要怎么搭建.
    qq529633582
        7
    qq529633582  
       2014 年 8 月 15 日
    hcymk2
        8
    hcymk2  
       2014 年 8 月 15 日
    要golang 的环境.
    zhujinliang
        9
    zhujinliang  
       2014 年 8 月 15 日
    我用openresty搭了一个自用,其实有nginx+echo模块就足够了
    missdeer
        10
    missdeer  
    OP
       2014 年 8 月 15 日
    @jamesxu
    听说过,域名没记住- -

    @binux
    @qq529633582
    主要是需要在curl ifconfig.xxx时返回一个干净的IP地址或其他参数的值,这样可以方便地用在shell脚本里

    @qiuai
    编译好的放在https://code.jd.com/missdeerme/ifconfig ,整个clone下来直接运行./ifconfig应该就行了,默认绑定端口8080,或改环境变量VCAP_APP_PORT
    missdeer
        11
    missdeer  
    OP
       2014 年 8 月 15 日
    @zhujinliang 那得自己有服务器- -
    archean
        12
    archean  
       2014 年 8 月 15 日
    dig +short myip.opendns.com @208.67.222.222 @208.67.220.220
    与 curl ifconfig.me 同样效果.
    qiuai
        13
    qiuai  
    PRO
       2014 年 8 月 15 日
    @missdeer 是64位环境的程序?
    # ./ifconfig
    -bash: ./ifconfig: cannot execute binary file
    missdeer
        14
    missdeer  
    OP
       2014 年 8 月 15 日
    @qiuai
    [tvu@localhost ifconfig]$ file ifconfig
    ifconfig: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
    qiuai
        15
    qiuai  
    PRO
       2014 年 8 月 15 日
    @missdeer 不知道...我用centos 32位跑.就提示
    -bash: ./ifconfig: cannot execute binary file
    missdeer
        16
    missdeer  
    OP
       2014 年 8 月 15 日
    @qiuai 嗯,我那个确实是64位的可执行文件。有第三方服务自动编译的 http://beta.gobuild.io/repo?id=256 下载对应版本的试试。
    msg7086
        17
    msg7086  
       2014 年 8 月 16 日
    难道不是nginx+add_header就能搞定的么……
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   954 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 20:21 · PVG 04:21 · LAX 12:21 · JFK 15:21
    ♥ Do have faith in what you're doing.