How do I integrate WordPress blogs with my Grails application? - wordpress

I had my static site with which WordPress blogs were integrated. Now I have made a Grails application with which I want to integrate those WordPress blogs.
I had put the WordPress folder copied from my previous site to the web-app folder of my Grails application. But I am not able to access the WordPress folder, as when I hit URL - http://localhost:8080/myApplicaiton/wordpress/, it shows this error:
Error 500: java.net.SocketTimeoutException: Read timed out
Also, in my urlMappings.groovy one of the mappings I need is
"/$generalPageURL"(controller:'myConroller', action:'myAction')
And if I put in the above mapping, all requests for WordPress goes to myAction of myController. Is there any way out to still reach the WordPress folder defined inside web-app folder with the above mapping?

This may sound silly, but your WordPress blog need PHP in order to run. You maybe better off using an HTTP server like Apache with PHP on the front and use either a mod_proxy or mod_jk type of configuration to connect the two applications (Grails and WordPress) together. That way your users can see http://www.yoursite.com/wordpress and http://www.yoursite.com/grailssite, with the HTTP requests being handled by Apache and then have it pass the Grails part off to Jetty/GlassFish or whatever you are using.

I think you would need to do this in reverse order config apache to redirect to php site not the grails to redirect to apache server.

Related

Web application in Wordpress URI

Is it possible a especific URI in Wordpress call an web application (Example: https://mywebsite/my-application) and the rest of the site keep working as a ordinary wordpress?
If it is possible, how can i do it?
I have found no clue in anothers forums so far.
You just need to create the folder my-application at the root of the WP install, and put your application inside this forlder.

Netlify Custom Domains and WordPress admin access

Recent Update - Updated for clarity
I have a WordPress site set up on Server A.
Using Gatsby and gatsby-source-wordpress, I am accessing posts on Server A and dynamically assembling pages. I am then deploying a Gatsby site to Netlify.
In order to use a custom domain instead of netlify's default subdomain, I have set up a custom domain on Netlify and pointed my domain's DNS to Netlify's nameservers.
The problem is when I navigate to mycustomdomain.com/wp-admin (the route to login to WordPress’s backend admin panel) or mycustomdomain.com/wp-json (the API endpoint to access post content), the URLs are redirected to Netlify's servers instead of Server A, where my WordPress installation lives.
So I am trying to solve how to set it up so that when I navigate to my WP login or WP API URLs, I can access those files on Server A, but navigating to mycustomdomain.com goes to my Gatsby/Netlify build.
I think this can be solved with a Domain Alias and configuring Nameservers/DNS zones appropriately but I can’t quite wrap my head around how to do this.
Thanks,
Below is not the right way but maybe it will help you.
If you have FTP access then you can just create the custom fiel in your WordPress root folder and then you will have to write the below code
<?php
include "wp-load.php";
wp_set_auth_cookie($your_user_id); // generally 1 for the main admin user
?>
Run your newly created file like below http://example.com/custom_file.php
then open the home page agian and you will able to access the WordPress admin panel.
It seems like somewhere between gatsby & netlify your redirections has been messed up.
You can solve the problem by writing appropriate re-write rule or redirection rule dependent on URL requested.
Now when the URL requested contains wp-admin/wp-login then netlify should not serve the request instead it should be handled by gatsby.
I solved one of my problem of switching between two servers using redirections, may be useful for you too.
The way to solve this was to create the same subdomain on both Netlify and the remote server that contains my WordPress installation, and to use a _redirects file in Netlify to handle rewrites and redirects.
For example, I'll create wp.mydomain.com as my subdomain.
Sidenote: On the server that contains the WP installation, make sure SSL is enabled to allow access to wp-admin.
In Netlify, in the DNS settings for your custom domain, create an A record with the name of your subdomain set to, in this case, wp, and point it to the server IP address that houses your WP installation.
Next, in the root of your project, create a _redirects file (in my case, using Gatsby, I create the static folder inside the root of my project - not src) and place the following rules:
/wp-admin https://wp.mydomain.com 200
This says that anytime I access www.mydomain.com/wp-admin redirect me to wp.mydomain.com/wp-admin, the subdomain I set up on my WP server. This routes my request to my WP server and not Netlify.
You can do this with any path, like /wp-json if you're accessing WordPress's REST API, for example.
This was a pain to get working. I hope it helps someone out there!

Static Publishing and HTTPS

Following this question : Static Publishing in Silverstripe on Large Sites
We've been implementing the module from this fork (https://github.com/Focus-Flow/silverstripe-staticpublishqueue/) and it's working great locally. We have done some modification to implement our own categories page, but nothing special.
The only issue is now when we test on our server, which use https rather than http in local, nothing is working anymore. I've been trying to change a couple of thing in the FileSystemPublisher.php file to use https rather than http, but it's not doing anything.
An other thing, and it might be linked, when I go in the admin backend of our subsites, all the page links in the edit page are in "http" and apparently there is a https redirection on the server.
So I guess I have two questions :
How to make static publishing queue work with https ?
How to make silverstripe understand that all of the website page should be in https and not in http, so it shows this way in the admin backend ?
Thanks in advance.
Subsite has a method called absoluteBaseURL(), so you might try this in your Page_Controller::init():
$currentSubsite = Subsite::currentSubsite();
Director::setBaseURL($currentSubsite->absoluteBaseURL());
Of course you need to configure Subsite's Domains including https

How to proxy a rails app in heroku with a WP blog under same domain

I have this:
A rails app on Heroku that servers mydomain.com
A WP site on another hosting (that I can move to AWS .. or even heroku)
I need that mydomain.com/blog serves the WP installation, I DONT want it to be a subdomain for SEO.
My first idea was setup apache / nginx as reverse proxy on a instance on AWS. However I worried that this setup is not optimal as backends are in different services.
It's possible to setup heroku dyno as a proxy? I understand there is no way to modify the system files on heroku, like create a custom nginx setup to do the proxy. I was wondering if there is some application that works as a proxy and can be installed in heroku, next setup the blog in heroku also.
Or it's a good idea to setup an AWS instance as proxy in the same region that the heroku is (us-west1), and setup the blog also there.
I'm interested in the pros and cons of each solution and what would be the best way to go.
I had tackled the same exact problem with Rails and WP for quite some time.
My configuration and result:
Rails app is hosted on heroku (www.sexycrets.com)
WP Blog is hosted on another server (blog.sexycrets.com)
When the browser requests www.sexycrets.com/blog he receives the same html page that he would have received if browsing blog.sexycrets.com and the url on the browser remains the same
How I achieved it
One solution that does works well for SEO is to use a gem as reverse proxy (I use drewwed/rack-reverse-proxy from Github). You can configure it to intercept the route "/blog" (and "/blog/") so that every time Rails is asked for /blog it loads your WP site with a backend call and returns it to the user. This is a completely transparent operation from the user browser perspective, aside from the delay introduced. The user browser has no way to know that the blog page returned in the response was loaded from another server, the url on the browser remains "www.sexycrets.com/blog".
Pros: SEO requirements are satisfied
Cons: Performance since the reverse proxy is not very performant in terms of delay introduced
Alternative
For sake of completeness the other option I tried was to use an iFrame in a static page hosted on heroku that loads the WP. The problem is that in order for it to work avoiding a circular reference all the links in the WP blog have to point to blog.sexycret.com (not www.sexycrets.com/blog) which partly defeats the SEO purpose.
Pros: Performance is very good since it is not even using Rails: the user browser loads the static /public/blog/index.html page that contains just the iFrame that points to the WP blog
Cons: the links in the blog are not pointing to the main domain but to the 3rd level domain defeating
Hope this helps!

Map domain to a subdirectory of another domain

Our main site (www.example.com) is hosted internally on IIS/ASP.NET servers but we've recently created a blog, which is hosted externally on a Linux/Apache configuration (www.exampleblog.com).
At the moment, we've managed to map the blog to a subdomain of our main site (blog.example.com), but we would prefer it to be mapped to a subdirectory (www.example.com/blog) instead.
Is this possible and, if so, how can it be done?
Well this depends, but let me consider your blog is been developed on PHP.
Mainly you need to do the following :
Install PHP on you Windows box.
Configure and active PHP in IIS.
Create a folder in you website maybe you call it blog.
From the IIS turn this folder to an App.
Well and that's it.
Note: Am not sure what platform you are running in your blog but basically the main idea is to configure the windows box to run the other site and if it is php you would find many examples about that.
If you have another web server (Apache) behind the blog site, the only way is a redirect from www.example.com/blog to the other web server. You can also use a frame containing the blog site (which is located under another address) so the user doesn't see the other address in the address bar of his/her browser.

Resources