Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 向heroku添加反向代理_Ruby On Rails_Heroku_Reverse Proxy - Fatal编程技术网

Ruby on rails 向heroku添加反向代理

Ruby on rails 向heroku添加反向代理,ruby-on-rails,heroku,reverse-proxy,Ruby On Rails,Heroku,Reverse Proxy,我有一个运行在heroku上的rails应用程序,例如myapp.herokuapp.com 现在我想将代理从myapp.heroku.com/proxy/反向代理到somewhere.com/(即:myapp.heroku.com/proxy/stuff反向代理到somewhere.com/stuff) 在希罗库有可能吗?如何实现这一点?您无法访问前端路由基础设施,因此无法添加类似nginx基于位置的反向代理或apache的modproxy之类的内容。根据我的理解,您也只能绑定到dyno中的一

我有一个运行在heroku上的rails应用程序,例如myapp.herokuapp.com

现在我想将代理从
myapp.heroku.com/proxy/
反向代理到
somewhere.com/
(即:
myapp.heroku.com/proxy/stuff
反向代理到
somewhere.com/stuff

在希罗库有可能吗?如何实现这一点?

您无法访问前端路由基础设施,因此无法添加类似nginx基于位置的反向代理或apache的modproxy之类的内容。根据我的理解,您也只能绑定到dyno中的一个端口($port),因此不可能使用自己的nginx供应商版本来隐藏Rails应用程序(除非nginx和你的rack/rails应用程序之间可以通过非TCP/IP套接字进行通信,否则如果是这样的话,也许你可以让rack听/tmp/mysocket.git,nginx在这个问题上反向代理,但这可能不是一个起点,我只是抛出了一些想法)


这意味着如果你必须自己在rails应用程序中处理这个问题,这是唯一可能的选择,我只有一点点rails/ruby的经验,但是如果rails中没有代理功能,那么你也许可以显式地接受路由,然后使用http客户机调用其他部分。

对于通过通过搜索,这是可以做到的

在heroku实例中查看供应商nginx。这将使nginx位于rails应用程序的前面,并允许您在该域上反向代理请求,将heroku应用程序配置为apex,并允许Somewhere.com/stuff转到其他位置