CloudFlare SSL setup - Images loaded from non-www version


(Shalin TJ) #1

Hi,

I recently setup Cloudflare for my discourse setup at https://www.ecitizen.org.in. I activated its Flexible SSL. Here’s the problem I encountered:

  1. the images are loaded from the non-www version. For instance, refer this post. Ideally, the URL of the images should be: https://www.ecitizen.org.in/uploads/default/original/1X/33b4cd5d4e027a9cb0f5f640ca29c12a97bab1b9.jpg . But they are https://ecitizen.org.in/uploads/default/original/1X/33b4cd5d4e027a9cb0f5f640ca29c12a97bab1b9.jpg .

Please do help me resolve this issue…

Happy Weekends…


(⛰️) #2

Greetings.

I do not use Cloudflare but I think I see a possible variable you may not have noticed in your setup.

This all depends on your SSL certificate.

SSL certificates sometimes only cover one domain name. (eg, ecitizen.org.in)

They also may cover one domain name and one subdomain. To my knowledge, www.ecitizen.org.in would be considered a subdomain. You have to manually configure the “www” subdomain in your root domain’s DNS settings.

This Cloudflare support article mentions this. (“You’re accessing a subdomain not covered by the CloudFlare-issued SSL certificate” and “The CloudFlare-issued SSL certificate is not yet active for your domain”)

I hope this may lead you to a possible solution for your situation.


(Shalin TJ) #3

Hi… Thanks for the reply… I’m using Cloudflare’s Flexible SSL. And they do cover www as well as non-www. Also, in my case I see that the certificate is already active…


(⛰️) #4

Excellent. That eliminates one possible variable.

Have you also configured the proper redirects?


(Shalin TJ) #5

I was able to resolve the duplication issue (that is, both www and non-www versions of the site being available). Now, if you enter https://ecitizen.org.in, you will be redirected to https://www.ecitizen.org.in.

But the images are still being loaded from non-www version. I have updated the actual question with this information.

Thanks…


(Matt Palmer) #6

You have almost certainly configured something in Discourse to use the non-www hostname in URLs. The easiest way to find it is to search all settings for ecitizen, and then look down the list of URLs for the one that’s incorrect. Fix it, and you’ll be on your way. You may have to “rebake” posts to update the URL in the cached version of the page, after you’ve made the change.


(Shalin TJ) #7

Hi Matt… I tried looking for settings related to “url” settings… Didn’t find anything that’s associated with the problem I mentioned above. Or did I miss anything?

Also what do you mean by rebaking posts?


(Matt Palmer) #8

Don’t look for “url” settings, look for any setting whose value includes your site name (ecitizen). The settings search finds both keys and values with the specified string.

“Rebaking” is our term for regenerating cached posts. We keep a cached copy of all posts because it saves a lot of CPU time when rendering pages, but when URLs change there are situations in which the cached posts have the old URL in them. To do a rebake, you’ll need to run:

./launcher enter
rake posts:rebake

(Shalin TJ) #9

Hi Matt… Sorry, but still not able to find the relevant setting. Here’s the screengrab. Can you be more specific on the exact field / settings detail that will help me resolve this issue?


(Matt Palmer) #10

Hmm, if it’s not in there, it’ll have to be in the app.yml config file. In that case, you’ll need to edit, rebuild the container image (./launcher rebuild, which will make the site unavailable for a few minutes), and then you’ll almost definitely need a rebake.


(Shalin TJ) #11

Scratching my head really hard now :slightly_smiling: . I’m not able to find any specific note / settings in the app.yml that helps in this regards… Can you point to anything more specific in app.yml???

Also, here’s another info that might help:

  1. When I hover on an image that will open the image in the lightbox, the URL of the image is shown something like this:

  2. But when I right-click and open the image in a new tab, the URL has www version of it.


(Shalin TJ) #12

hey… bumping up the thread to check for help…

Thanks…