Two rails apps sharing session behind the same reverse proxy

Hi there!

Currently, I have a rails (5.2.2.1) app behind a nginx reverse proxy in a old debian. Ruby it’s installed from packages.

I want to develop some new parts, in a new rails app (and different box maybe) with the last rails version, and place it under same domain. Having a reverse proxy seems easy pease. The reverse proxy isn’t the problem

But, which it’s the best option to “share” data session between this two apps? Initially it’s for sharing something like basically info, but can grow.

We are using the same approach successfully.

  • Since it’s the same domain, the browser would send both session cookies to both apps
  • You can access the cookies via ActionController::Cookies

I’d recommend setting up the reverse proxy in development, and investigating the sessions/cookies from both apps in your browser’s dev tools and in Rails via the cookies method. This would give you some idea how it would work.

1 Like