简体   繁体   English

如何为heroku上托管的Rails应用程序设置QuotaGuard Static?

[英]How to setup QuotaGuard Static for a Rails app hosted on heroku?

I'm trying to setup my heroku app to have an static IP using QuotaGuard (I know proximo is the other option, but it's pretty expensive). 我正在尝试使用QuotaGuard设置我的heroku应用程序以获得静态IP(我知道proximo是另一种选择,但它非常昂贵)。

I added the heroku QuotaGuard Static addon and got the two IPs it generates as well as the proxy url. 我添加了heroku QuotaGuard静态插件,并获得了它生成的两个IP以及代理URL。

What is my next step? 我下一步要做什么? (aka how do I tell my Rails app to use the proxy provided by QuotaGuard) (又如何告诉我的Rails应用程序使用QuotaGuard提供的代理)

  • I see they have ruby code samples using REST-client and HTTParty, but do I put that somewhere like in the application.rb?? 我看到他们使用REST-client和HTTParty有ruby代码示例,但是我把它放在应用程序中的某个地方.rb ??

Most likely a bit too late to answer this question, but still. 回答这个问题很可能有点太迟了,但仍然如此。

Like you said, the first step to configuring QuotaGuard Static is provisioning the addon on Heroku (either via the Web Interface or the Heroku CLI). 如您所说,配置QuotaGuard Static的第一步是在Heroku上配置插件(通过Web界面或Heroku CLI)。 From there, you are able to get your two outbound IPs, and your proxy URL. 从那里,您可以获得两个出站IP和代理URL。 The two IPs you were given should be whitelisted on whichever remote service you are trying to access. 您尝试访问的任何远程服务都应将您提供的两个IP列入白名单。

As you mentioned, the documentation gives you a couple of samples using Rest Client for Ruby on Rails. 正如您所提到的,文档为您提供了一些使用Rest Client for Ruby on Rails的示例。 This snippet should pretty much go anywhere you want to access whichever resource you need to access via the static IP Addresses. 这个代码段应该可以随意访问您需要通过静态IP地址访问的任何资源。 Assuming you want to access a Web Service hosted on an Amazon EC2 instance with elastic IP 1.2.3.4, your would write: 假设您想要使用弹性IP 1.2.3.4访问托管在Amazon EC2实例上的Web服务,您可以写:

RestClient.proxy = ENV["QUOTAGUARDSTATIC_URL"]
res = RestClient.get("http://1.2.3.4/yourWebService")

And from there process the response stored in res appropriately. 并从那里处理适当存储在res中的响应。 This code would go in say whichever controller's method you'll be using to access the remote web service. 这段代码将说明您将用于访问远程Web服务的控制器方法。 In this case, you also need to add the Rest Client to your controller, so at the top of that file you shoud also add require "rest-client" . 在这种情况下,您还需要将Rest Client添加到控制器,因此在该文件的顶部,您还应添加require "rest-client" Don't forget to add the rest-client gem to your Gemfile. 不要忘记将rest-client gem添加到Gemfile中。

Summing up, basically the snippets from the documentation go wherever it is you want to use the proxy to access a remote service requiring a fixed, whitelisted set of IP addresses. 总而言之,基本上文档中的代码片段无论您希望使用代理来访问需要固定的白名单IP地址的远程服务。

Source: https://devcenter.heroku.com/articles/quotaguardstatic 资料来源: https//devcenter.heroku.com/articles/quotaguardstatic

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Heroku如何在Rails 3应用程序上设置Resque Web? - Heroku how to setup resque web on a rails 3 app? 如何为 rails 的 heroku 站点设置 Facebook 应用程序? - how to setup facebook app for heroku site for rails? 强制长臂猿宝石(或法拉第)在Heroku上使用QuotaGuard静态HTTP代理 - Forcing Gibbon Gem (or Faraday) to use QuotaGuard Static HTTP proxy on Heroku 在Heroku的Rails应用程序中托管s3上托管的静态页面的最佳方法 - best method for serving static pages hosted on s3 in rails app on heroku 我的应用程序在Heroku中托管的ruby on rails中出错 - Error in my app in ruby on rails hosted in heroku 我如何创建从WordPress(驻留在wsynth上)到Heroku托管的Rails应用的301重定向? - How do I create 301 redirect from WordPress (hosted on wsynth) to a Rails app hosted on Heroku? 如何使用Heroku / Rails 4应用设置新的Redshift数据库 - How to setup new Redshift database with Heroku/Rails 4 app 已添加到Heroku上的Rails应用程序中。 如何在本地环境中设置数据库? - Added to Rails app on Heroku. How to setup database in local environment? 从Rails应用程序外部托管的Rails应用程序中提供静态内容 - Serving static content from a Rails app, hosted outside of the Rails app 如何从 Heroku 中托管的 Rails API 应用程序在浏览器中设置 cookie,该应用程序在 Netlify 中托管的 React 应用程序中运行前端? - How can I set cookies in a browser from a Rails API app hosted in Heroku running the frontend in a React app hosted in Netlify?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM