[chef-dev] Merb and URL rewriting


Chronological Thread 
  • From: Alan Milligan < >
  • To:
  • Subject: [chef-dev] Merb and URL rewriting
  • Date: Wed, 04 Apr 2012 20:26:19 +1000

I've had to make a couple of minor hacks to chef-server-api and chef-server-webui to allow them to rewrite paths properly when used with ProxyPass/RewriteRule's.

This is particularly important when you want to reach both servers behind a single Apache/SSL server (or other favourite proxy server).

Seems all that's necessary is to pass :path_prefix into Merb::Config[:path_prefix] in the config/init.rb.

Thus, in /etc/chef/webui.rb,

# chef_server_url specifies the URL for the server API. The process actually
# listens on 0.0.0.0:PORT. valid values are any HTTP URL. To change the port
# the server listens on, modify /etc/sysconfig/chef-server.

chef_server_url    "http://localhost:4000";

# if you're doing virtual hosting with ProxyPass/Rewrites, and need the chef
# server to rewrite the path prefix, set this here

path_prefix        "chefapi"


And in Apache VirtualHost, something along the lines of:

      RequestHeader set X-Forwarded-Proto "https"
      RewriteEngine on
      #RewriteLogLevel 10

      RewriteRule ^/chefapi/?(.*)$ http://localhost:4000/$1 [L,P]
      RewriteRule ^/chefui/?(.*)$ http://localhost:4040/$1 [L,P]

      # everything else to a real *Python* server ...
RewriteRule ^/(.*)$ http://localhost:8080/VirtualHostBase/https/%{HTTP_HOST}:%{SERVER_PORT}/plone/VirtualHostRoot/$1 [L,P]


I do have patches for 0.10.8, but it's quite simple, and I'm also not sure how far you've progressed with the rails migration.

Regards,
Alan


  • [chef-dev] Merb and URL rewriting, Alan Milligan, 04/04/2012

Archive powered by MHonArc 2.6.16.

§