Skip to content

Rework trusted proxies - #5549

Merged
Alkarex merged 4 commits into
FreshRSS:edgefrom
Alkarex:CONN_REMOTE_ADDR
Jul 30, 2023
Merged

Alkarex merged 4 commits into
FreshRSS:edgefrom
Alkarex:CONN_REMOTE_ADDR

Conversation

@Alkarex

@Alkarex Alkarex commented Jul 26, 2023

Copy link
Copy Markdown
Member

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

Alkarex commented Jul 26, 2023

Copy link
Copy Markdown
Member Author

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

@d-k-bo

d-k-bo commented Jul 26, 2023

Copy link
Copy Markdown

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
@Alkarex
Alkarex deleted the CONN_REMOTE_ADDR branch July 30, 2023 10:59

@joestump joestump left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread lib/lib_rss.php
if (empty($trusted)) {
$trusted = FreshRSS_Context::$system_conf->trusted_sources;
}
foreach (FreshRSS_Context::$system_conf->trusted_sources as $cidr) {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Alkarex added a commit that referenced this pull request Jun 5, 2026
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