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

Rework trusted proxies #5549

Merged
merged 4 commits into from Jul 30, 2023
Merged

Rework trusted proxies #5549

merged 4 commits into from Jul 30, 2023

Conversation

Alkarex
Copy link
Member

@Alkarex Alkarex commented Jul 26, 2023

Fix #5502
Follow-up of #3226

New environment variable TRUSTED_PROXY: set to 0 to disable, or to a list of trusted IP ranges compatible with https://httpd.apache.org/docs/current/mod/mod_remoteip.html#remoteiptrustedproxy

New internal environment variable CONN_REMOTE_ADDR to remember the true IP address of the connection (e.g. last proxy), even when using mod_remoteip.

Current working setups should not observe any significant change.

Fix FreshRSS#5502
Follow-up of FreshRSS#3226

New environment variable `TRUSTED_PROXY`: set to 0 to disable, or to a list of trusted IP ranges compatible with https://httpd.apache.org/docs/current/mod/mod_remoteip.html#remoteiptrustedproxy

New internal environment variable `CONN_REMOTE_ADDR` to remember the true IP address of the connection (e.g. last proxy), even when using mod_remoteip.

Current working setups should not observe any significant change.
@Alkarex
Copy link
Member Author

Alkarex commented Jul 26, 2023

To ease testing, I have pushed a Docker image freshrss/freshrss:pr5549

@d-k-bo
Copy link

d-k-bo commented Jul 26, 2023

From what I can tell, the image works fine on my system, using Caddy's reverse_proxy directive without any additional options. I can access the server from an external network and the log still shows my real IP address.

Thank your for working on this!

@Alkarex Alkarex merged commit e768945 into FreshRSS:edge Jul 30, 2023
1 check passed
@Alkarex Alkarex deleted the CONN_REMOTE_ADDR branch July 30, 2023 10:59
Copy link
Contributor

@joestump joestump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alkarex let me know if you'd like me to file a separate issue on this.

if (empty($trusted)) {
$trusted = FreshRSS_Context::$system_conf->trusted_sources;
}
foreach (FreshRSS_Context::$system_conf->trusted_sources as $cidr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alkarex I've been trying to get this working with Authentik and staring at this logic for a bit. Am I crazy or does this completely override the $trusted logic on line 684?

On line 684 $trusted gets set, then if it's empty() on line 687 it gets overridden with FreshRSS_Context::$system_conf->trusted_sources, but is ignored for the rest of the function as it defers to FreshRSS_Context::$system_conf->trusted_sources on this line.

I currently have TRUSTED_PROXY set to 192.168.1.34/32, $trusted gets set, and then this falls through to false on line 695.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this should probably be something like:

Suggested change
foreach (FreshRSS_Context::$system_conf->trusted_sources as $cidr) {
foreach ($trusted as $cidr) {

Do you feel like sending a PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alkarex that did the trick: #5853

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

Successfully merging this pull request may close these issues.

[BUG] Mishandling of X-Forwarded-For ?
3 participants