Forum: Ruby on Rails Cartographer/google maps and apache2/mongrel problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5b9ee1ffcaf5ce4c4299d18d5f110044?d=identicon&s=25 Paul Mylchreest (Guest)
on 2007-05-04 01:00
(Received via mailing list)
Hi,

I'm trying to make cartographer/google maps work with an apache2/
mongrel setup.

It works fine with lighttpd/fastcgi, however maps don't render with
the above setup.

I was wondering if anyone had any success trying this.

Here is what my mongrel configuration file looks like:

<<-=======================================
---
cwd: /home/paulm/rails_apps/myapp/current
port: "10011"
environment: staging
address: localhost #127.0.0.1
pid_file: log/mongrel.pid
servers: 1
=======================================

and my apache2 config:

<<-=======================================
<VirtualHost *:80>
   ProxyPreserveHost On
   ProxyPass         /     http://localhost:10010/
   ProxyPassReverse  /     http://localhost:10010/
   ServerName my.domain.net
   #Fix for Apache bug 39499
   SetEnv force-proxy-request-1.0 1
   SetEnv proxy-nokeepalive 1
</VirtualHost>

Listen localhost:10010
<VirtualHost localhost:10010>
   ServerName my.domain.net
   DocumentRoot /home/paulm/rails_apps/myapp/current/public

   <Directory "/home/paulm/rails_apps/myapp/current/public">
     Options FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from all
   </Directory>

   Include /home/paulm/rails_apps/myapp/current/config/
mongrel_cluster/common.conf

   <Proxy balancer://mongrel_cluster>
     BalancerMember http://localhost:10011
   </Proxy>
</VirtualHost>
=======================================


I registered an api key for my domain put in the cartographer config
file, restarted the mongrel cluster and httpd and I get this when
looking at the produced html:

<<-=======================================
<!-- Cartographer Header goes here.  The URI [localhost:10011]
couldn't be found in your
       cartographer-config.yml file.  Please add it and your map
initialization code will
       appear here. Otherwise, perhaps your YML is misformed -->
=======================================


As a side note, I tried out this configuration:

<<-=======================================
---
cwd: /home/paulm/rails_apps/myapp/current
port: "10011"
environment: staging
pid_file: log/mongrel.pid
servers: 1
=======================================

with a registered api key "my.domain.net:10011", and bypassing
apache2 works.

So, I'm wondering if I'm missing some apache2 configuration magic here!

TIA,
Paul
5b9ee1ffcaf5ce4c4299d18d5f110044?d=identicon&s=25 Paul Mylchreest (Guest)
on 2007-05-04 17:28
(Received via mailing list)
The problem is with cartographer. When it tries to lookup the api
key, it uses HTTP_HOST in the request. In this setup, its the mongrel.

Here is the fix for vendor/plugins/cartographer/lib/cartographer/
header.rb:

<<===
   def self.header_for(request, version=2)
     mh = self.new
     mh.version = version
     #uri = request.request_uri
     #uri = uri[0..uri.rindex('/')] if uri.rindex('/') < uri.length
     mh.uri = request.env['HTTP_X_FORWARDED_HOST'].split(',')[0]
rescue request.env["HTTP_HOST"] #+ uri
     mh.to_s
   end
===
This topic is locked and can not be replied to.