DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

Running Multiple Domains Off A Single Rails App With Different Page Caching Directories

Snippets Manager user avatar by
Snippets Manager
·
Oct. 08, 05 · · Code Snippet
Like (0)
Save
Tweet
614 Views

Join the DZone community and get the full member experience.

Join For Free
Problem: You have multiple instances of a rails app that use page caching, but you'd rather not set up a separate instance for each one.

Lighttpd config:
#... normal lighty conf...
server.document-root = "/home/rails/app/public/"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (
  ".fcgi" =>
    ("localhost" =>
      (
       "min-procs" => 1,
       "max-procs" => 1,
       "socket" => "/tmp/rails-fcgi1.socket",
       "bin-path" => "/home/rails/app/public/dispatch.fcgi",
       "bin-environment" => (
         "RAILS_ENV" => "production",
         "TZ"        => "America/Chicago"
       )
     )
    )
 )

$HTTP["host"] =~ "site1.net" {
  server.document-root = "/home/rails/app/public/site1.net"
}
$HTTP["host"] =~ "site2.net" {
  server.document-root = "/home/rails/app/public/site2.net"
}


Rails code to set the page cache directory:

before_filter { |c| c.class.page_cache_directory = "#{RAILS_ROOT}/public/#{c.request.host}" }

Remember to symlink your necessary files AND your dispatch.fcgi to each page cache directory.
app

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The Most Popular Kubernetes Alternatives and Competitors
  • Is Java Still Relevant?
  • 10 Steps to Become an Outstanding Java Developer
  • How to Submit a Post to DZone

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo