Static Publishing and HTTPS - silverstripe

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

Related

Why WordPress image link in not appearing after activating SSL?

I've successfully added SSL on my WordPress website and it's every URL is working well with https URL but there seems all images is missing. In dashboard, all images URL is converted to https URL but in front-end they are not showing any URL it just seems like
Please anyone could help me to solve this issue?
This is likely because the URLs to the images are now http, and may be being blocked by browser security settings. There's a handy plugin I often use to help sort out issues like this called Really Simple SSL:
https://wordpress.org/plugins/really-simple-ssl/
This plugin manages the URLs to include the correct protocol, etc. You may need to change any hard-coded URLs in your theme that do not use https however.

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!

How can I solve the OpenShift Wordpress installation certificate and hence the https permalink issues?

I've migrated my Wordpress blog to OpenShift recently. It works perfect until when you try to add a custom domain alias to your installation.
The OpenShift URL for my blog is blog-latifetunc.rhcloud.com
I added the following URL as alias: blog.latifetunc.com
(Sorry I couldn't attach images since I don't have enough reputation points. Instead I put links to images. This is my first question in StackOverflow.)
http://www.alpertunc.com/q1.png
I successfully added the CNAME record for my domain to point blog.latifetunc.com to blog-latifetunc.rhcloud.com in GoDaddy
http://www.alpertunc.com/q2.png
The problem pops up when I try to reach my blog with this alias. It says:
Safari can't verify the identity of the website "blog.latifetunc.com".
The certificate for this website is invalid. You might be connecting to a website that is pretending to be "blog.latifetunc.com", which could put your confidential information at risk. Would you like to connect to the website anyway?
(I can't even post more than two links without 10 reputation points :( So please put the above URL in front of below images as well.)
q3.png
If you click "Continue" it works fine but this alert is very scary for many users. I searched for hours for a solution with no luck. I considered buying a security certificate as well but then I thought this blog was working with an alias in its previous installation too. However we never had such an alert in browser while visiting either via the main domain or the alias.
The previous installation was on IIS and the binding were as following:
q4.png
Then when my brain was about to explode I found out that the alert is due to https. When I checked Settings from my Wordpress dashboard I realised that somehow OpenShift installs Wordpress on https and sets the permalinks to https.
q5.png
In fact whatever you type that points to *.rhcloud.com is converted to https. I know that because I added the CNAME for www.latifetunc.net to point to blog-latifetunc.rhcloud.com as well but didn't add the alias in OpenShift Applications. So www.latifetunc.net resolves to blog-latifetunc.rhcloud.com but since there is no alias defined (hence there is no vhost entry in Apache) it gives error. But even that error is in port 443!
q6.png
My main problem is to get rid of the certificate error while visiting my blog via my alias domain name. I really appreciate any help on that one.
My related question is that why on earth permalinks start with https on OpenShift Wordpress installation? If I can solve that, probably I'll solve my main problem as well.
Thanks a lot!
I checked blog.latifetunc.com on safari,chrome,firefox, and opera and I didn't get any warnings so you much have figured out a solution. However for others who may stumble across this I've provided some information:
By default OpenShift applications accept traffic on both http and https. So if you're wanting to have a custom domain but aren't worried about ssl than you can simply just use the http connection to your application (http://myapp.com). If you are wanting to apply a SSL certificate and you're on one of the plans that allow it (bronze or silver). The documentation to apply it, is in the SSL Section of the OpenShift Online User Guide.

SSL and relative URLs in site links and redirections

I have been working on a website in beta phase for some time now, and am finally about to launch it. There are several links, anchor tags, with relative URLs throughout the site that link to the admin and cart sections of the website, and now they have to be SSL secured.
Also, same question for relative URLs in Response.Redirect("~/../..");
When a user is browsing over http, is there anyway to redirect them to a page with https connection using a relative URL? It seems like poor practice to code absolute URLs for links and redirections for the purpose of SSL. If the domain name changes, I have to rewrite them all. Plus, if I want them to work on my localhost, I would have to change them every time I upload to server. There must be some solution.
Switching Between HTTP and HTTPS Automatically is a very good code to use for the implementation of switching logic fast and easy - and not change your existing code.
Similar: Preparing my ASP.NET / MVC site to use SSL?
These helper methods by Rick Strahl will help you
http://www.west-wind.com/weblog/posts/2007/Sep/18/ResolveUrl-without-Page
Pay special attention to ResolveServerUrl.
Depending on what version of IIS you are running, you could always offload this functionality to the webserver. Check out the URL Rewrite module here.

How do I integrate WordPress blogs with my Grails application?

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.

Resources