addons icon indicating copy to clipboard operation
addons copied to clipboard

Update trusted_proxies to match docker.address range

Open eRaid6 opened this issue 7 months ago • 4 comments

Updating DOCS.md to reflect that HA/Supervisor uses 172.30.32.0/23 network for docker so trusted_proxies should match or it's possible for connections to fail with a error of Connection refused) while connecting to upstream.

~# ha net info
docker:
  address: 172.30.32.0/23
  dns: 172.30.32.3
  gateway: 172.30.32.1
  interface: hassio

See https://community.home-assistant.io/t/nginx-configuration-connection-refused/62407 and https://github.com/home-assistant/supervisor/blob/7c6c982414794172298b2f29ce2358df062b1c0a/supervisor/const.py#L35 for additional info.

Summary by CodeRabbit

  • Documentation
    • Updated the example configuration to expand the trusted proxy IP range, now covering both 172.30.32.0/24 and 172.30.33.0/24 subnets.

eRaid6 avatar May 08 '25 12:05 eRaid6

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar May 08 '25 12:05 home-assistant[bot]

📝 Walkthrough

Walkthrough

The documentation for the NGINX Proxy add-on was updated to expand the example trusted_proxies IP range in the Home Assistant configuration from 172.30.33.0/24 to 172.30.32.0/23, thereby including a wider range of trusted proxy addresses.

Changes

File(s) Change Summary
nginx_proxy/DOCS.md Updated example trusted_proxies configuration to use a broader subnet (172.30.32.0/23).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomeAssistantConfig
    participant NGINXProxy

    User -> HomeAssistantConfig: Edits configuration.yaml
    HomeAssistantConfig -> NGINXProxy: Sets trusted_proxies: 172.30.32.0/23
    NGINXProxy -> HomeAssistantConfig: Accepts requests from expanded IP range

[!TIP]

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar May 08 '25 12:05 coderabbitai[bot]

Updating DOCS.md to reflect that HA/Supervisor uses 172.30.32.0/23 network for docker so trusted_proxies should match or it's possible for connections to fail with a error of Connection refused) while connecting to upstream.

Well, the proxy runs as an add-on, and gets an IP from the IP assignment pool, which is DOCKER_NETWORK_RANGE. So your Proxy should always get an IP from the 172.30.33.0/24 range.

That said, widen the range doesn't hurt. But it really should not be necessary.

Did you actually encounter that issue? What IP did the NGINX proxy add-on have at that time?

agners avatar May 09 '25 09:05 agners

Uh, could it be that your clients connect through IPv6? In that case it seems that the proxy sees the hassio host IP 172.30.32.1 (see also this discussion).

However, defining 172.30.32.1 as trusted proxy IP is not the right solution here, as this would mean all IPv6 addresses are considered trusted. We need to have a NGINX proxy which can make proper IPv6 sockets such that the source IP is correctly mapped to the connecting IPv6 address.

agners avatar May 12 '25 16:05 agners