Page rule to bypass Flag 301 when https redirection is forced and HSTS enabled

Hi,

is possible to bypass HTTP > HTTPS redirection together with HSTS enabled via page rules?

I have some zip file located: http://example.com/public/FilesFolder/Zip_File.zip. If I try to download that file I will get redirected to https. But I need to use http for this specific URL because I’m running NSIS installer which can download by default only via HTTP.

I tried to setup Page Rule like this:
If the URL matches:
http://example.com/public/FilesFolder/Zip_File.zip

**Then the settings are:**
Automatic HTTPS rewrites: OFF

But I’m still being redirected. Testing via wget --max-redirect=0 but still get HTTP request sent, awaiting response… 301 Moved Permanently

I’m using for this domain Cloudflare Proxy (orange cloud). Do you have some tip how to bypass this?

Thank you for any tips.

“Automatic HTTPS rewrites” is the setting for replacing http:// links in the HTML with https://, it’s not the setting for Cloudflare’s http -> https redirect for requests themselves.

That would be the “always use HTTPS” setting - which can’t be disabled on a per-request basis (can only be enabled on a per-request basis) - since it doesn’t have a toggle when used in page rules.

The only way to achieve this would be to turn off the global “always use HTTPS” setting and have two page rules:

Page rule 1: match http://example.com/public/FilesFolder/Zip_File.zip
Setting: dummy setting (eg “always online off”)

Page rule 2: match http://*example.com*
Setting: Always use HTTPS

Page rule 2 would be lower priority than page rule 1.

Since only one page rule can apply per URL, your first “dummy” page rule would apply, and not the second one, making it so CF doesn’t perform the 301 redirect. All other matches would hit the second page rule though, and be redirected to https.


As for your use case

But I need to use http for this specific URL because I’m running NSIS installer which can download by default only via HTTP.

If you use INetC, it uses Internet Explorer which does support HTTPS urls

I did setup like your example Judge and it works!

I searched before for INetC, but for me it’s hard to re-distribute and pack new application to end users. I will need to repack whole installer for our game server as well. That’s why I was looking for the workaround and you solved it! :+1:

Thank you!

1 Like

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