How to setup a WordPress blog with a Ruby on Rails web app?
ID: 1618225
Wordpress with Rails (Bildquelle: Netlings Webworks Pvt. Ltd. )(firmenpresse) - These days, a great blog alongside its main web app is a must have for any SaaS provider. While Ruby on Rails is best when it comes to building a web app, WordPress is number #1 when it comes to blogging.
Why WordPress on Rails?
A blog can definitely be built using Rails itself. But WordPress is already so well optimised and ready to use in a few clicks, that you don?t need to do code a blog from scratch.
Building your own blog solution, or using some existing gems, might still be the best option if you want an entire Rails integration (login, etc?). Or maybe you particularly enjoy doing it. Or maybe you require a very simple version of a blog. Otherwise, and the vast majority of case, it is just unnecessary additional work. WordPress on Rails is the best solution for these cases.
Best Wordpress + RubyOnRails Setup
Wordpress & Rails don?t usually play nice together. So the best option is host RubyOnRails web app on your root domain and host Wordpress blog on a subdomain.
For example:
A Ruby on Rails app can be hosted on Heroku: https://www.awesomeapp.com
A Wordpress blog can hosted on WPEngine: https://blog.awesomeapp.com
You can obviously host both main and sub-domain on single server as well. Netling's website and client login is built on RubyOnRails and our blog is running on Wordpress hosted on a single DigitalOcean VPS instance managed with Plesk Onyx AdminPanel.
However, this is not an ideal situation. For maximum search engine optimisation you want your blog to be accessed as a subdirectory???not as a subdomain. So essentially you want to achieve something like this:
A Ruby on Rails app hosted on Heroku: https://www.awesomeapp.com
A Wordpress blog hosted on WPEngine: https://www.awesomeapp.com/blog
This brings us to the main question,
How to host a RubyOnRails app on a root domain and a Wordpess blog on a subdomain and still be able to access blog as a sub-directory?
The answer is, put Wordpress blog behind a reverse proxy!
Setup root domain server hosting RubyOnRails app as reverse proxy to forward all requests made for your blog to subdomain running Wordpress. For example, setup https://www.awesomeapp.io as a reverse proxy to forward any requests made to https://www.awesomeapp.com/blog to https://blog.awesomeapp.com.
Typically, this requires changing configuration of your Apache or NGINX instance, but we will use a handy rails gem to achieve the same results - rack-reverse-proxy .
On your Rails app
Add the rack-reverse-proxy gem to your gemfile:
gem 'rack-reverse-proxy', :require => 'rack/reverse_proxy'
Then, you need your Rails app to redirect /blog/ to your Wordpress blog on subdomain. Go to config.ru and add the following code:
use Rack::ReverseProxy do
reverse_proxy(/^/blog(/.*)$/, 'https://blog.awesomeapp.com$1', opts = { preserve_host: true })
end
Note: Make sure you don?t have a trailing ?/? in your URL. It should be https://blog.awesomeapp.com$1 and not https://blog.awesomeapp.com/$1
Since the blog is technically hosted at /blog/, we need to forward the /blog requests there (notice the non-trailing slash).
Add to config/routes.rb:
get "/blog", to: redirect('https://www.awesomeapp.com/blog/', status: 301)
On your Wordpress blog
In your wp-config.php add following lines:
/**
* Handle SSL reverse proxy
*/
if ($_SERVER == 'https')
$_SERVER='on';
if (isset($_SERVER)) {
$_SERVER = $_SERVER;
}
$_SERVER = "/blog".$_SERVER;
Conclusion
Voilà, you have your beautiful Wordpress blog alongside your powerful Ruby on Rails app.
Thanks for reading! I will keep it updated and add more relevant info in it as needed. If you need any help in getting this setup, don?t hesitate to tweet me: @netlings.Weitere Infos zu dieser Pressemeldung:
Unternehmensinformation / Kurzprofil:
Netling web development studio is located in New Delhi, India. We are a studio small enough to be cohesive and agile enough to approach every single project with devotion, care and flexibility. Yet, big enough to accept coding challenges of all shapes and sizes.
Netlings Webworks Pvt. Ltd.
Dipesh Batheja
C-3/1, 2nd Floor, Phase-2, Ashok Vihar 42263490
110052 Delhi
dipesh(at)netlingshq.com
09999352696
https://www.netlingshq.com
Datum: 07.06.2018 - 09:35 Uhr
Sprache: Deutsch
News-ID 1618225
Anzahl Zeichen: 4907
Kontakt-Informationen:
Ansprechpartner: Dipesh Batheja
Stadt:
Delhi
Telefon: 09999352696
Kategorie:
Auto & Verkehr
Diese Pressemitteilung wurde bisher 365 mal aufgerufen.
Die Pressemitteilung mit dem Titel:
"How to setup a WordPress blog with a Ruby on Rails web app?"
steht unter der journalistisch-redaktionellen Verantwortung von
Netlings Webworks Pvt. Ltd. (Nachricht senden)
Beachten Sie bitte die weiteren Informationen zum Haftungsauschluß (gemäß TMG - TeleMedianGesetz) und dem Datenschutz (gemäß der DSGVO).
Weitere Mitteilungen von Netlings Webworks Pvt. Ltd.
SmartTOP Verdecksteuerung von Mods4cars für Audi R8 Spyder 4S ab sofort erhältlich ...
Nevada, Las Vegas - 07. Juni 2018 Ab sofort ist die SmartTOP Verdecksteuerung der Firma Mods4cars für den neuen Audi R8 Spyder 4S ab Baujahr 2016 erhältlich. "Es freut uns, dass wir nun auch ein SmartTOP für den neuen R8 Spyder anbieten können. Bereits seit 2013 unterstützen wir das Vo
PostNord setzt bei Inter-Hub-Transporten auf 51 neue Kögel Box Trockenfrachtkoffer ...
Die schwedisch-dänische Postgesellschaft PostNord Sverige AB mit Hauptsitz in Solna in der Provinz Stockholm in Schweden setzt künftig auf 51 neue Kögel Box Trockenfrachtkoffer für den Transport von Briefen und Paketen zwischen den Hubs der beiden Länder. PostNord hat sich für die 2-Achs-Varia
Neues Kraftpaket in der Reihe der ODU-MAC® Module ...
Da Hochstromanwendungen z.B. durch die Elektromobilität und die dazugehörige Ladetechnik auch bei der Mess- und Prüftechnik immer wichtiger werden, bietet ODU seinen Kunden in der ODU-MAC® Blue-Line ab sofort zusätzlich ein neues Hochstrom-Modul an. Mit einem Kontaktdurchmesser von 12 mm ist
Studie Automobilbarometer 2018 - Kundenbeziehung im Umbruch ...
Kundenbeziehung im Umbruch -Die Treue zur Automarke ist zerbrechlich -Marken müssen digital erweiterte Kauferlebnisse schaffen Lebenslange Treue zu einer Automarke ist heute nicht mehr selbstverständlich. Überall locken neue Produkte und Angebote. Die Spirale technischer Innovationen dre




