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

nginx_proxy: Adding support for TCP Proxy Protocol #3274

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

miguelrjim
Copy link

@miguelrjim miguelrjim commented Oct 21, 2023

This allows Nginx to support the TCP proxy protocol, this is useful if you still want to TLS terminate on the home-assistant host but you have another entrypoint for all your TLS connections (i.e. traefik is your entrypoint and you redirect from it to home-assistant based on the HTTPS domain being requested, this makes sure that any kind of network request to home-assistant remains encrypted).

What this allows is that home-assistant will know the true ip of the user making requests (making this change because I saw in the logs that there was a failed log-in but the ip pointed to my traefik instance).

Tested this by installing these changes as a local add-on on home-assistant.

@bvli

This comment was marked as off-topic.

@miguelrjim
Copy link
Author

Hi @agners, just wondering what would be the next step to get the PR merged?

Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

I am not very familiar with the various proxy options/configurations, but wouldn't the first option documented in https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/ to get the originating IP address more generic? (E.g. not using the RealIP module? 🤔 ).

nginx_proxy/config.yaml Outdated Show resolved Hide resolved
nginx_proxy/config.yaml Outdated Show resolved Hide resolved
servers: str?
proxyProtocol:
enabled: bool
realIpFrom: str?
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should support a list? 🤔

Copy link
Author

Choose a reason for hiding this comment

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

What field were you thinking?

Copy link
Member

Choose a reason for hiding this comment

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

You can ask the user for a list, the Samba add-on has an example for it's allowed host list, syntax would be:

  allow_hosts:
    - str

I am not sure how to make this optional though. 😅

Copy link
Author

Choose a reason for hiding this comment

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

There's definitely some improvements that can be done into how this addon is setup; will definitely take a look later to see about these other kind of changes as well.

@home-assistant
Copy link

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

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft March 11, 2024 09:24
@miguelrjim
Copy link
Author

I am not very familiar with the various proxy options/configurations, but wouldn't the first option documented in https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/ to get the originating IP address more generic? (E.g. not using the RealIP module? 🤔 ).

Hmm it could be? Tbh i've been using $proxy_protocol_addr as that was being used in a couple of other examples with proxy protocol.

@agners
Copy link
Member

agners commented Mar 12, 2024

Hmm it could be? Tbh i've been using $proxy_protocol_addr as that was being used in a couple of other examples with proxy protocol.

There is also this note:

The Real‑IP modules for HTTP and Stream TCP are not included in NGINX Open Source by default; see Installing NGINX Open Source for details. No extra steps are required for NGINX Plus.

🤔

I am really not an expert in NGINX/Proxy setups. But I think if things can work without the RealIP module, it seems the better approach to me.

nginx_proxy/config.yaml Outdated Show resolved Hide resolved
nginx_proxy/rootfs/etc/s6-overlay/s6-rc.d/nginx/run Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft April 25, 2024 10:03
@miguelrjim miguelrjim marked this pull request as ready for review April 26, 2024 03:30
@home-assistant home-assistant bot requested a review from agners April 26, 2024 03:30
@agners agners changed the title Adding support for TCP Proxy Protocol nginx_proxy: Adding support for TCP Proxy Protocol Apr 26, 2024
nginx_proxy/config.yaml Outdated Show resolved Hide resolved
@miguelrjim miguelrjim requested a review from agners May 6, 2024 05:22
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.

None yet

3 participants