I have an application running on a Lighttpd instance which is proxied by
an
Apache server. It seems to work fine but my urls are incorrect: all urls
reference / which is not where my application runs at the Apache server.
How do I set the base url of a Rails application?
On Mon, Mar 06, 2006 at 05:03:52PM +0100, Bart B. wrote:
} I have an application running on a Lighttpd instance which is proxied
by an
} Apache server. It seems to work fine but my urls are incorrect: all
urls
} reference / which is not where my application runs at the Apache
server.
} How do I set the base url of a Rails application?
}
} My Apache has the following proxy rules:
} ProxyPass /hieraki http://localhost:3001
} ProxyPassReverse /hieraki http://localhost:3001
} But links in the Hieraki main page are like
} http://someserver.com/xml/rss for the RSS feed
} and http://someserver.com/wiki/folder/show/ROOT for the root.
So you did… the correct answer is to use Rails’ relative_url_root.
Although a config option for this setting is currently MIA, you can
set it in your environment by doing
I tested this solution today and it does not work. I tried it on hieraki
and
I get urls like www.someserver.com/myurl/wiki/folder/show and when I
click
those I get
Recognition failed for “der/show/ROOT”
So the stripping does not seem to work?
I tested this solution today and it does not work. I tried it on hieraki
and I get urls like www.someserver.com/myurl/wiki/folder/show and when I
click those I get
Recognition failed for “der/show/ROOT”
So the stripping does not seem to work?
Update: I discovered the problem (but no solution). I am running Apache
as a
proxy for a local Rails setup. So I proxy www.someserver.com/myurl to
localhost:3000 and I ask Rails to append myurl.
But Rails also strips myurl when receiving a request, even worse: it
only
strips the number of characters in myurl. In my case it was thiswiki so
8
characters, so www.someserver.com/myurl/wiki/folder/show/ROOT has www.someserver.com stripped off which results in
myurl/wiki/folder/show/ROOT and then 8 characters are stripped off:
der/show/ROOT.
How should this be fixed? Did I do something wrong with the url_for
method
and should that work? Is this method completely wrong? I can’t be the
only
one in this situation, right?
On Tue, Mar 07, 2006 at 09:50:12AM +0100, Bart B. wrote:
} Bart B. wrote:
}
} > Nicholas S. wrote:
} >
} >> On Mar 6, 2006, at 11:38 AM, Gregory S. wrote:
} >>
} >>> I just answered another question with similar information. See
} >>> Apache 2.x: Use fcgid or Mongrel? - Rails - Ruby-Forum
} >>
} >> So you did… the correct answer is to use Rails’
relative_url_root.
} >> Although a config option for this setting is currently MIA, you can
} >> set it in your environment by doing
} >>
} >> ActionController::AbstractRequest.relative_url_root = ‘/the/prefix/
} >> rails/should/add/to/generated/links/and/remove/from/incoming/paths’
} >>
} > I tested this solution today and it does not work. I tried it on
hieraki
} > and I get urls like www.someserver.com/myurl/wiki/folder/show and
when I
} > click those I get
} > Recognition failed for “der/show/ROOT”
} > So the stripping does not seem to work?
}
} Update: I discovered the problem (but no solution). I am running
Apache as a
} proxy for a local Rails setup. So I proxy www.someserver.com/myurl to
} localhost:3000 and I ask Rails to append myurl.
} But Rails also strips myurl when receiving a request, even worse: it
only
} strips the number of characters in myurl. In my case it was thiswiki
so 8
} characters, so www.someserver.com/myurl/wiki/folder/show/ROOT has
} www.someserver.com stripped off which results in
} myurl/wiki/folder/show/ROOT and then 8 characters are stripped off:
} der/show/ROOT.
} How should this be fixed? Did I do something wrong with the url_for
method
} and should that work? Is this method completely wrong? I can’t be the
only
} one in this situation, right?
So now that I know the right way to do things, I can talk about how to
make
it work. Basically, you can’t use:
Now Rails will strip and add exactly what it should.
When using this with
ActionController::AbstractRequest.relative_url_root =’/foo/bar’
I can’t get my regular toy example to work because I get
Recognition failed for “”
With hieraki routing seems to work (why?) but the CSS and javascript
fails.
When surfing to the CSS or Javascripts I get messages like:
Recognition failed for “/stylesheets/base.css”
Recognition failed for “/javascripts/effects.js”
What is going on here? Is the routing not working in Rails? Or is this
use
of Apache as a proxy so uncommon?
Bart
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.