I am using Apache2.2 + Mongrel on my machine.
Now I am accessing it over LAN. When I enter http://mymachinename/myapp
it opens fine but when I click on any link in my rails app, it replaces
mymachinename with localhost (http://localhost/myapp/controller/action)
and thus I am unable to access it from remote location.
On 11/7/07, Geek M. [email protected] wrote:
I am using Apache2.2 + Mongrel on my machine.
Now I am accessing it over LAN. When I enter http://mymachinename/myapp
it opens fine but when I click on any link in my rails app, it replaces
mymachinename with localhost (http://localhost/myapp/controller/action)
and thus I am unable to access it from remote location.
Geek,
It sounds to me like your apache is not passing the hostname through
properly. Not enough information here for me to help more than that.
Good luck,
~Wayne
Quoting Geek M. [email protected]:
I am using Apache2.2 + Mongrel on my machine.
Now I am accessing it over LAN. When I enter http://mymachinename/myapp
it opens fine but when I click on any link in my rails app, it replaces
mymachinename with localhost (http://localhost/myapp/controller/action)
and thus I am unable to access it from remote location.
Why are your links absolute urls at all? Are you using absolute or
relative link syntax in your rails app? W/o more info, it isn’t clear
where the ‘http://localhost/’ part is being introduced into the
equation.
here it is…
=======
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
Alias /myapp “c:/rails/myapp/public”
Alias /images “c:/rails/myapp/public/images”
Alias /stylesheets “c:/rails/myapp/public/stylesheets”
Alias /javascripts “c:/rails/myapp/public/javascripts”
<Directory “c:/rails/myapp/public”>
Options Indexes FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
ProxyPass /images !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass /myapp/ http://127.0.0.1:4000/
ProxyPass /myapp http://127.0.0.1:4000/
ProxyPassReverse /myapp/ http://127.0.0.1:4000/
ProxyPassReverse /myapp http://127.0.0.1:4000/
And there’s following like in Apache’s httpd.conf
Include conf/httpd-webrick-proxy.conf
Quoting Vapor … [email protected]:
what kind of info is required to clear it more?
Like my httpd-proxy.config file?
Thats the only thing I added to the system.
Give an example of the rails code that generates on of the links that
says localhost. Are you using link_to?
Then, yes, show us your proxy configuration (with sensitive info
xxxx’ed out)
–
Cynthia K.
what kind of info is required to clear it more?
Like my httpd-proxy.config file?
Thats the only thing I added to the system.
Your Rails code looks fine and should give you normal urls as far as I
can see. I am afraid I don’t use ProxyPass and Directory directives; I
use mod_rewrite + VirtualHost stanzas. So I hope someone else on the
list can see what is funky.
At a glance, this stanza looks fairly normal - though I haven’t see
folks do /myapp and /images in parallel. Is your Rails site a
subsection of another site?
Quoting Vapor … [email protected]:
Cynthia K. wrote:
Quoting Vapor … [email protected]:
what kind of info is required to clear it more?
Like my httpd-proxy.config file?
Thats the only thing I added to the system.Give an example of the rails code that generates on of the links that
says localhost. Are you using link_to?Then, yes, show us your proxy configuration (with sensitive info
xxxx’ed out)–
Cynthia K.
yes exactly…
<%= link_to(‘Home’, :controller => ‘post’, :action => ‘index’) %>
Isn’t it right?
I’m assuming all of your configuration below is not in a VirtualHost
block? If so, what’s the value of your ServerName directive? It should
read:
ServerName mymachinename
I know the same ProxyPass and ProxyPassReverse directives (with the
proper ServerName) work if you put it in a VirtualHost block, but I’m
not entirely sure otherwise.
-Ripta
Alias /myapp “c:/rails/myapp/public”
Alias /images “c:/rails/myapp/public/images”
Alias /stylesheets “c:/rails/myapp/public/stylesheets”
Alias /javascripts “c:/rails/myapp/public/javascripts”
<Directory “c:/rails/myapp/public”>
Options Indexes FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
ProxyPass /images !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass /myapp/ http://127.0.0.1:4000/
ProxyPass /myapp http://127.0.0.1:4000/
ProxyPassReverse /myapp/ http://127.0.0.1:4000/
ProxyPassReverse /myapp http://127.0.0.1:4000/And there’s following like in Apache’s httpd.conf
Include conf/httpd-webrick-proxy.conf
Nothing worked!
But the solution was somewhere else…It took me 4 hours to find that I
had to change BASE_URL in my ‘reverse_proxy_fix’ plugin from
http://localhost/myapp to http://mymachinename/myapp
:S
Gotta get some sleep
We had something similar in Apache when proxying twice (slightly odd
internal architecture). We to brute-force the Host: header in my
site’s httpd.conf:
RequestHeader set Host railsapp.example.com
And, as others have suggested, make sure your ServerName directive is
set properly.
-Nate
Thank you for posting the solution.
~Wayne