Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urlinfo scheme is "http" when website is behind Cloudflare #478

Open
fujaru opened this issue May 10, 2024 · 5 comments
Open

Urlinfo scheme is "http" when website is behind Cloudflare #478

fujaru opened this issue May 10, 2024 · 5 comments

Comments

@fujaru
Copy link

fujaru commented May 10, 2024

When accessing the website with "https" but the website itself is hosted behind a proxy or load balancer such as Cloudflare, a lot of buttons such as create new content/folder, publish etc don't work. By opening browser dev tools I found ajax requests are sent with "http" instead of "https" and so the browser blocked it.

A likely reason is because a connection between client to the proxy server is done with https, but connection between the proxy server and the actual web server is done with http.

I could make it work by modifying system.php:137 to check for HTTP_X_FORWARDED_PROTO header.

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
	$uri = $uri->withScheme($_SERVER['HTTP_X_FORWARDED_PROTO']);
}
$urlinfo 				= Urlinfo::getUrlInfo($basepath, $uri, $settings);

Based on these articles, this header is added by proxy servers to indicate what protocol is used between the client and proxy server.
https://developers.cloudflare.com/fundamentals/reference/http-request-headers/#x-forwarded-proto
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto

@trendschau
Copy link
Member

Yes, did you try the proxy-detection in the developer tab of the system settings? There is a proxy detection and if it does not work in complex environments you can also force an url/schema

@fujaru
Copy link
Author

fujaru commented May 10, 2024

Thank you for pointing out the settings!
I tested enabling proxy as well as setting a base-url under the developer tab and these options didn't work unfortunately. When editing a content for example, clicking Publish button showed the ajax request was still sent to the same url with http (not the one that was set in base-url).

@trendschau
Copy link
Member

Thank you for the Information, that is strange, I only tested it with a local proxy but some clients use it successfully. I will check if I can test it with cloudflare somehow.

@trendschau
Copy link
Member

Sorry, just published a new release, I will have a look in the next days...

@trendschau
Copy link
Member

Yes, i see the problem, will be fixed with release 2.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants