Enabling cloudflare in a subdomain redirects to main domain and redirects wrong

Hello,
I have a main domain and a static subdoamin.

If I enable Cloudflare in the static subdomain. All pages like https://static.xxxxx.com/folder/image1 become https://xxxxx.comfolder/image1.

There are 2 things:
-First. I don’t want my subdomain to be redirected to the one without “static”.
.Second. It is doing it wrong, is missing the first slash.

In my server I have a redirection from http to https for the main domain.
I don’t have any redirection for the static as it is not intended to be accessed directly. I don’t understand how cloudflare works but it is attachinng a 301 redirect when I enable it in the subdomain.

What am I doing wrong?

Thanks.

None of your hosts are being proxied by Cloudflare (they are all :grey:) so this is an issue on your origin.

It is not proxied anymore because I just disabled it because it was ruining the site. I disabled it and after a very hard work clearing caches in my browsers I finally was able to use the site again.

You have no page rules which would be rewriting URLs through Cloudflare. So it seems like it would be an origin issue.

I think the problem is that cloudflare is caching the http version instead of the https. As I didn’t have any http version of static subdomain the default was to redirect to https main domain.

I made an experiment changing the http://static and thats exactly what it shows when I enable the proxy even I enter https://static.

If I try to make the redirect for http://static to https://static when I enable cloudflare proxy it becomes and infinite redirection loop, becase it is caching the http instead of https.

Now I understand cloudflare caches the content from port 80 even if I access the page from port 443.
I guess if I have a page that works both http and https cloudflare proxy would work. I don’t want to, I see cloudflare have a function to force https, but I don’t know what would it do.

What would be the best approach for my site?

I finally found the solution.

I made the static site available from port 80 (http) using HSTS to force browsers use https, this way cloudflare gets the right content and it works using https.
I think redirect approach is now obsolete and unnecessary as now exists Strict-Transport-Security. Anyway I will enable cloudflare later because I will be working on the site. I see there is a “development mode” but it lasts 3 hours. I don’t need the proxy right now. I was only doing tests because I didn’t want my site to fail in production.

Thank you for your replies.

This topic was automatically closed after 31 days. New replies are no longer allowed.