# Apache as proxy for webrick

**URL:** <https://www.ruby-forum.com/t/apache-as-proxy-for-webrick/57022>\
**Category:** Rails\
**Created:** [April 6, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/apache-as-proxy-for-webrick/57022 "2006-04-06T16:49:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@tomx](https://www.ruby-forum.com/u/tomx)\
**Post date:** [April 6, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/apache-as-proxy-for-webrick/57022/1 "2006-04-06T16:49:29Z")

</div>

Hello,

We have a webrick server running our nice app, and an apache server  
being used to serve the rest of the site and act as a proxy for the  
webrick app.

`

```
ProxyRequests Off

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass /appname http://server.com:3000
ProxyPassReverse /appname http://server.com:3000
ProxyPreserveHost On

```

`

If you go to [http://server.com/appname](http://server.com/appname) everything seem to work fine,  
however when the app needs to redirect it strips the appname out of the  
path. e.g. [http://server.com/redirectcontroller/redirectaction](http://server.com/redirectcontroller/redirectaction)  
Apache gets all confused because it can’t find the file and returns a  
404 error.

Does anyone know how to stop the /appname from being removed from the  
URL?  
Thanks  
Tom

---

<div class="post-metadata">

**Author:** ![tomx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@tomx](https://www.ruby-forum.com/u/tomx)\
**Post date:** [April 6, 2006, 5:27pm UTC](https://www.ruby-forum.com/t/apache-as-proxy-for-webrick/57022/2 "2006-04-06T17:27:42Z")

</div>

On 4/6/06, Tom S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> ProxyPass /appname http://server.com:3000
> ProxyPassReverse /appname http://server.com:3000
> ProxyPreserveHost On
> 
> ```

> Does anyone know how to stop the /appname from being removed from the  
> URL?

Couldn’t you change your proxy to use [http://server.com:3000/appname](http://server.com:3000/appname)  
and then add “/appname” to your routes?

– James

---

<div class="post-metadata">

**Author:** ![tomx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@tomx](https://www.ruby-forum.com/u/tomx)\
**Post date:** [April 6, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/apache-as-proxy-for-webrick/57022/3 "2006-04-06T17:41:25Z")

</div>

> Couldn’t you change your proxy to use [http://server.com:3000/appname](http://server.com:3000/appname)  
> and then add “/appname” to your routes?

I’d rather avoid having the port in the path at all unless there is no  
way around it.

How would I go about altering all routes to use a preset root directory  
name?

Cheers  
Tom

---

<div class="post-metadata">

**Author:** ![tomx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@tomx](https://www.ruby-forum.com/u/tomx)\
**Post date:** [April 6, 2006, 6:01pm UTC](https://www.ruby-forum.com/t/apache-as-proxy-for-webrick/57022/4 "2006-04-06T18:01:26Z")

</div>

On 4/6/06, Tom S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Couldn’t you change your proxy to use [http://server.com:3000/appname](http://server.com:3000/appname)  
> > and then add “/appname” to your routes?
> 
> I’d rather avoid having the port in the path at all unless there is no  
> way around it.

I meant this:

ProxyPass /appname [http://server.com:3000/appname](http://server.com:3000/appname)  
ProxyPassReverse /appname [http://server.com:3000/appname](http://server.com:3000/appname)

You were already using the port, so I didn’t think you wanted to get rid  
of it.

> How would I go about altering all routes to use a preset root directory  
> name?

# Allow downloading Web Service WSDL as a file with an extension

# instead of a file named ‘wsdl’

map.connect ‘appname/:controller/service.wsdl’, :action =\> ‘wsdl’

# Install the default route as the lowest priority.

map.connect ‘appname/:controller/:action/:id’

I haven’t tried this, but I don’t see why it wouldn’t work either.

– James
