# Mongrel/win32/apache2 link modification question

**URL:** <https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527>\
**Category:** Rails\
**Created:** [July 7, 2006, 6:47pm UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527 "2006-07-07T18:47:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@John\_I](https://www.ruby-forum.com/u/John_I)\
**Post date:** [July 7, 2006, 6:47pm UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527/1 "2006-07-07T18:47:50Z")

</div>

I have apache2 - mongrel 0.3.13.3-mswin32 running, on a server 2000  
pc, by folowing the ‘Serving Multiple Rails Applications on Windows  
with Apache and Mongrel’ ( [http://tinyurl.com/z9ftz](http://tinyurl.com/z9ftz) )

the question I have is why is why is [http://localhost/myapp/](http://localhost/myapp/) addded to  
the front of all my links and how can I stop it?

origanal link using webrick /employees/edit/1214  
now it’s  
[http://localhost/myapp//employees/edit/1214](http://localhost/myapp//employees/edit/1214)

John I.

---

<div class="post-metadata">

**Author:** ![John\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@John\_I](https://www.ruby-forum.com/u/John_I)\
**Post date:** [July 7, 2006, 9:30pm UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527/2 "2006-07-07T21:30:13Z")

</div>

answer to my problem…

a,?address (:host)  
Address to bind to when listening for connections.  
\* Default: 0.0.0.0 (every interface)

thanks for the documentation/site zed.

---

<div class="post-metadata">

**Author:** ![John\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@John\_I](https://www.ruby-forum.com/u/John_I)\
**Post date:** [July 7, 2006, 9:44pm UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527/3 "2006-07-07T21:44:00Z")

</div>

John:  
I’m the author of that article. Would you please elaborate more on your  
problem? Are you using the reverse\_proxy\_fix plugin?

---

<div class="post-metadata">

**Author:** ![John\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@John\_I](https://www.ruby-forum.com/u/John_I)\
**Post date:** [July 7, 2006, 10:10pm UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527/4 "2006-07-07T22:10:07Z")

</div>

I am using the reverse\_proxy\_fix plugin.

my web server is a 2k box we’ll call ‘webserver’.  
when I accessed [http://webserver/myapp/controller](http://webserver/myapp/controller) locally  
the page shows up, but the links point to  
[http://localhost/myapp//controller/action/id](http://localhost/myapp//controller/action/id) (this is from the source  
from the displayed page)  
my stylesheet was pionting to  
[http://localhost/myapp//stylesheets/scaffold.css?1147879980](http://localhost/myapp//stylesheets/scaffold.css?1147879980)

which will work as long as i’m on webserver.  
If I went to another pc, say ‘winxp’ and I went to  
‘[http://webserver/myapp/controller](http://webserver/myapp/controller)’ the page displays, but the links  
don’t ‘work’ because it is trying to access localhost. follow?

so I stoped and removed the mongrel sevice then I reinstalled using  
this.  
mongrel\_rails service::install -N intranet -c c:\web\intranet -p 4001  
-e development -a 192.168.10.246  
(it’s an internal server)  
and started the service. it’s running.  
Now I go to [http://webserver/myapp/controller](http://webserver/myapp/controller) all the links go to  
/controller/action/id (from web page source).  
so now the links don’t work because the app name (myapp) is not in the  
url path.  
do I need to do something with route?  
I would actually like hide the application from the URL.  
so instead of [http://server/myapp/controller](http://server/myapp/controller)  
it would be [http://server/controller](http://server/controller)

I’m not sure If I confused you or made it more clear

thanks.  
john

---

<div class="post-metadata">

**Author:** ![John\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@John\_I](https://www.ruby-forum.com/u/John_I)\
**Post date:** [July 7, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527/5 "2006-07-07T22:29:22Z")

</div>

I’m not sure you’re using the reverse\_proxy\_fix plugin correctly. The  
plugin  
only works properly in PRODUCTION mode

Make sure you configure the config.rb file to point to the correct  
outbound  
address you need.

[http://server/controller/myapp/](http://server/controller/myapp/)

Then

mongrel\_rails service::install -N intranet -c c:\web\intranet -p 4001-e  
production -a 192.168.10.246

The plugin will fix your URLs for you.

To make it just [http://server/controller](http://server/controller) you will need to modify the  
proxy  
settings in Apache (remove the alias folder and use document root). Then  
change the path in the config.rb for reverse\_proxy\_fix to point to  
[http://server/controller](http://server/controller)

Don’t touch routes!

---

<div class="post-metadata">

**Author:** ![John\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@John\_I](https://www.ruby-forum.com/u/John_I)\
**Post date:** [July 8, 2006, 3:36am UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527/6 "2006-07-08T03:36:30Z")

</div>

On Fri, 2006-07-07 at 14:29 -0500, John I. wrote:

> answer to my problem…
> 
> a,â??address (:host)  
> Address to bind to when listening for connections.  
> \* Default: 0.0.0.0 (every interface)
> 
> thanks for the documentation/site zed.

Another approach is to set the X-Fowarded-For header in the web server  
in front. Weird thing is Apache is supposed to do this already when it  
proxies a connection. Mongrel will pick-up this header and set  
REMOTE\_HOST to it so that rails gets the routing and rewrites correct.

Run your app with one mongrel and the -B option turned on for a couple  
requests. Then go look at the log/mongrel\_debug/rails.log file and see  
what headers it’s giving to your rails app. If REMOTE\_HOST says  
localhost then something’s not right with your apache config. If you  
don’t see X\_FORWARDED\_FOR as well then research via google how to set it  
with mod\_header and force it to the vhost.

–  
Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

[http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)  
[http://www.railsmachine.com/](http://www.railsmachine.com/) – Need Mongrel support?

---

<div class="post-metadata">

**Author:** ![John\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@John\_I](https://www.ruby-forum.com/u/John_I)\
**Post date:** [July 10, 2006, 6:49pm UTC](https://www.ruby-forum.com/t/mongrel-win32-apache2-link-modification-question/97527/7 "2006-07-10T18:49:56Z")

</div>

Brian,  
Got it to work, I didn’t notice i was in development mode.  
thanks for you help.

john
