Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mask my landing page when user not signed in?

I got my web platform built on ruby on rails at https://example.com

My landing and about pages are hosted in a Wordpress in other host at https://examplecms.com.

What i would like to achieve is to make users to visit https://example.com get masked https://examplecms.com except when they are logged in as my platform's dashboard is routed in the root path /.

What i am trying to avoid is the user to see in the URL https://examplecms.com.

I've tried so far a couple of tricks:

  • In my home/index action controller i've redirected to https://examplecms.com if the user is not signed in. But this fails as it still shows the CMS url in the user's browser.
  • Using an Iframe in the render of the home/index view pointing to the CMS site. It works because it stills present my site URL correctly but this seems kind of fishy also deep linking and navigating does not seem to work correctly.

I have been thinking into doing at proxy server level, using .htaccess or even using DNS strategies but i can't come up for a solution to these strategies to detect when the user is signed in or not?

Any ideas?

Thanks

Update: Stack:

  • Ubuntu
  • Ruby on Rails
  • Nginx + passenger
  • Amazon Ec2 + Cloudflare DNS
like image 852
David Mauricio Avatar asked Apr 13 '18 19:04

David Mauricio


1 Answers

You can use http://nginx.org/r/proxy_pass to silently redirect the user to a different page, without changing the URL that's shown to the user within the Location field of the browser.

To check whether the user is logged in, you can install an error handler via http://nginx.org/r/error_page to redirect the user only if your normal page returns an error (e.g., if the normal proxy_pass results in a 403 Forbidden response, then redirect the user's request to the alternative proxy_pass upstream as per the error handler).

like image 129
cnst Avatar answered Nov 03 '22 15:11

cnst