# Proxy, routes.rb, and urls

**URL:** <https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220>\
**Category:** Rails\
**Created:** [March 26, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220 "2007-03-26T21:14:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jetskers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jetskers](https://www.ruby-forum.com/u/jetskers)\
**Post date:** [March 26, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220/1 "2007-03-26T21:14:26Z")

</div>

Wondering if this is possible in an elegant global way to adjust RoR’s  
urls…

Basically what I would like to do is make Rails aware that it needs to  
have to adjust all the urls that refer to itself by a preceeding “/  
rails” in the urls. I’ve tried things in routes.rb such as “map.test  
‘rails/:controller, :action’”, etc…, but to no avail. Currently the  
only way I’ve been able to do this is to more or less hard code it  
( which may not be too bad of a thing in this case ) in any .rhtml  
files with a link\_to adjustment, as in  
\<%= link\_to “newBYE”, :controller =\> “/rails/hello”, :action =\>  
“list\_times” %\>

Not knowing RoR well enough yet to know if this is going to be a  
problem… but it seems to me a routes.rb generating solution would be  
better. I wouldn’t think this would be that hard, but perhaps it’s  
to much away from “convention over configuration”.

The reason I want to do this is because at first we’ll be using Apache  
to proxy Rails requests, and the ‘/rails’ is the flag for Apache to  
hit on the reverse proxy.

Thanks for any information,

-Dave

---

<div class="post-metadata">

**Author:** ![jetskers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jetskers](https://www.ruby-forum.com/u/jetskers)\
**Post date:** [March 26, 2007, 10:32pm UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220/2 "2007-03-26T22:32:36Z")

</div>

jetskers wrote:

> files with a link\_to adjustment, as in  
> hit on the reverse proxy.
> 
> Thanks for any information,
> 
> -Dave

Since you’ll be using Apache you can have it do the work for you by  
doing something like:

ProxyPass /rails [http://127.0.0.1:3000/](http://127.0.0.1:3000/)  
ProxyPassReverse /rails [http://127.0.0.1:3000/](http://127.0.0.1:3000/)

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![jetskers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jetskers](https://www.ruby-forum.com/u/jetskers)\
**Post date:** [March 26, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220/3 "2007-03-26T23:07:06Z")

</div>

Well, yes, of course, and that’s what I’m doing.

But how do I tell applications in rails to write links that refer to  
applications  
written in rails to put in /rails in those url’s?

---

<div class="post-metadata">

**Author:** ![jetskers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jetskers](https://www.ruby-forum.com/u/jetskers)\
**Post date:** [March 26, 2007, 11:37pm UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220/4 "2007-03-26T23:37:11Z")

</div>

Well, yes, of course, and that’s what I’m doing.

But how do I tell applications in rails to write links that refer to  
applications  
written in rails to put in /rails in those url’s?

---

<div class="post-metadata">

**Author:** ![jetskers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jetskers](https://www.ruby-forum.com/u/jetskers)\
**Post date:** [March 26, 2007, 11:22pm UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220/5 "2007-03-26T23:22:10Z")

</div>

jetskers wrote:

> Well, yes, of course, and that’s what I’m doing.
> 
> But how do I tell applications in rails to write links that refer to  
> applications  
> written in rails to put in /rails in those url’s?

If you are using Mongrel you can do it like this:

mongrel\_rails start -d -p 3000   
-a 127.0.0.1   
-e production   
–prefix /rails

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![jetskers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jetskers](https://www.ruby-forum.com/u/jetskers)\
**Post date:** [March 27, 2007, 12:13am UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220/6 "2007-03-27T00:13:16Z")

</div>

Well, yes, of course, and that’s what I’m doing.

But how do I tell applications in rails to write links that refer to  
applications  
written in rails to put in /rails in those url’s?

---

<div class="post-metadata">

**Author:** ![jetskers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jetskers](https://www.ruby-forum.com/u/jetskers)\
**Post date:** [March 27, 2007, 12:44am UTC](https://www.ruby-forum.com/t/proxy-routes-rb-and-urls/90220/7 "2007-03-27T00:44:19Z")

</div>

oops… shouldn’t be hitting that reload button.
