Heroku静态IP地址(不Proximo) [英] Static IP Address with Heroku (not Proximo)

查看:327
本文介绍了Heroku静态IP地址(不Proximo)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让Heroku服务器获得一个静态IP地址?我正在尝试整合各种请求IP地址的API。由于Heroku的服务器设置,你永远不会有一台具有静态IP的服务器 - 相反,你的IP是动态的。



我已经研究过像Proximo这样的附加组件,似乎是一种付费解决方案。有没有一个解决方案,你有一个静态IP,你不必支付?

解决方案

您可以使用 QuotaGuard Static Heroku附加组件。

QuotaGuard可以通过命令行连接到Heroku应用程序:

  $ heroku addons:add quotaguardstatic 

安装完成后,应将应用程序配置为与加载项完全集成。
当您注册时,您将获得一个唯一的用户名和密码,您可以在您的应用程序中配置您的代理服务时使用



QUOTAGUARDSTATIC_URL设置为在应用程序配置中可用,并将包含您应用于代理您的API请求的完整URL。
这可以使用下一个命令来确认:

  $ heroku config:get QUOTAGUARDSTATIC_URL 
http:/ /user:pass@static.quotaguard.com:9293

您通过此代理进行的所有请求将对于目标服务器来说,它似乎来自您注册时将分配给您的两个静态IP中的一个。



您可以使用Ruby的简单HTTP和REST客户端检测您的IP:

  $ gem install rest-client 

接下来,您可以在IRB会话中运行以下示例,并验证返回的最终IP是您的两个静态IP中的一个。

  $ irb 

> requirerest-client

> RestClient.proxy ='http:/ /user:pass@static.quotaguard.com:9293'

> res = RestClient.get(http://ip.jsontest.com)

就是这样:)


Is there a way to get one Static IP address for a Heroku Server? I'm trying to integrate various API's which ask for an IP address. Because of Heroku's server setup, you never have one server with a static IP - instead your IP is dynamic.

I've looked into add-ons like Proximo, however this appears to be a paid-for solution. Is there a solution where you have a static IP that you don't have to pay for?

解决方案

You can use QuotaGuard Static Heroku add-on.

QuotaGuard can be attached to a Heroku application via the command line:

$ heroku addons:add quotaguardstatic

After installing, the application should be configured to fully integrate with the add-on. When you sign up you will be provided with a unique username and password that you can use when configuring your proxy service in your application

A QUOTAGUARDSTATIC_URL setting will be available in the app configuration and will contain the full URL you should use to proxy your API requests. This can be confirmed using the next command:

$ heroku config:get QUOTAGUARDSTATIC_URL
http://user:pass@static.quotaguard.com:9293 

All requests that you make via this proxy will appear to the destination server to originate from one of the two static IPs you will be assigned when you sign up.

You can use A simple HTTP and REST client for Ruby for detecting your IP:

$ gem install rest-client

Next, you can run the below example in an IRB session and verify that the final IP returned is one of your two static IPs.

$ irb

>require "rest-client"

>RestClient.proxy = 'http://user:pass@static.quotaguard.com:9293'

>res = RestClient.get("http://ip.jsontest.com")

That's it:)

这篇关于Heroku静态IP地址(不Proximo)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆