# Problem with redirect\_to() and VirtualHost

**URL:** <https://www.ruby-forum.com/t/problem-with-redirect-to-and-virtualhost/107461>\
**Category:** Rails\
**Created:** [June 21, 2007, 11:48pm UTC](https://www.ruby-forum.com/t/problem-with-redirect-to-and-virtualhost/107461 "2007-06-21T23:48:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iceburgh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@iceburgh](https://www.ruby-forum.com/u/iceburgh)\
**Post date:** [June 21, 2007, 11:48pm UTC](https://www.ruby-forum.com/t/problem-with-redirect-to-and-virtualhost/107461/1 "2007-06-21T23:48:53Z")

</div>

I’m running into a problem with redirect\_to() and Apache’s  
VirtualHost facility. I have probably have something set up  
wrong, but I’m not even sure how to approach the problem.

Background:

We have DNS set up to return the domain’s address for all  
sub-domains. So, “dig [xyz.cfcl.com](http://xyz.cfcl.com)” returns the same IP  
address as “dig [cfcl.com](http://cfcl.com)”.

Our router forwards ranges of port numbers to specified  
machines. So, a request on port 1234 might go to “fido”.

We are using Apache’s VirtualHost facility to redirect (?)  
requests to certain machines, as:

```
<VirtualHost *:80>
  ServerName xyz.cfcl.com
  ServerAdmin removed_email_address@domain.invalid
  ErrorLog /dev/null
  CustomLog /dev/null common
  ProxyRequests Off
  ProxyPass / http://fido.cfcl.com:1234/
  ProxyPassReverse / http://fido.cfcl.com:1234/
</VirtualHost>

```

As a result, requests to [http://xyz.cfcl.com](http://xyz.cfcl.com) are answered  
by a Rails server that is set up to answer port 1234 on  
[fido.cfcl.com](http://fido.cfcl.com). This (mostly) works fine, both inside and  
outside of the LAN.

Problem:

If a user enters an invalid value into a form, we want to  
set up the “flash” hash and redirect back to the page that  
contained the form. Something like:

```
flash[:notice] = get_errors()
redirect_to(:back)

```

This works (on the LAN) when the URL of the form page is:

```
http://fido.cfcl.com:1234/conf/edit_new

```

However, if the URL is:

```
http://xyz.cfcl.com/conf/edit_new

```

the redirect results in:

```
Proxy Error

The proxy server received an invalid response from an
upstream server.

The proxy server could not handle the request POST
/conf/create.

Reason: Document contains no data

```

The server says:

```
[2007-06-21 14:18:42] ERROR URI::InvalidURIError:
the scheme http does not accept registry part:
xyz.cfcl.com (or bad hostname?)
/usr/local/lib/ruby/1.8/uri/generic.rb:729:in `merge'
...

```

Any ideas on what might be wrong or (better) how to fix it?

## -r

[http://www.cfcl.com/rdm](http://www.cfcl.com/rdm) Rich M.  
[http://www.cfcl.com/rdm/resume](http://www.cfcl.com/rdm/resume) removed\_email\_address@domain.invalid  
[http://www.cfcl.com/rdm/weblog](http://www.cfcl.com/rdm/weblog) +1 650-873-7841

Technical editing and writing, programming, and web development
