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

Add docs for rewrite client IP settings #2701

Merged
merged 7 commits into from
Oct 21, 2024

Conversation

salonichf5
Copy link
Contributor

Proposed changes

Write a clear and concise description that helps reviewers understand the purpose and impact of your changes. Use the
following format:

Problem: User needs documentation explaining how to configure rewrite client IP settings.

Solution: Adds documentation on how to configure rewrite client IP settings

Testing: Manual testing using make watch docs.

Screenshot 2024-10-18 at 1 07 26 PM

Please focus on (optional): If you any specific areas where you would like reviewers to focus their attention or provide
specific feedback, add them here.

Closes #2517

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.


@salonichf5 salonichf5 requested review from a team as code owners October 18, 2024 20:08
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 18, 2024
@salonichf5 salonichf5 force-pushed the docs/rewrite-client-ip-settings branch from 4415cc8 to d119f84 Compare October 18, 2024 20:09
Copy link
Contributor

Deploy Preview will be available once build job completes!

Name Link
😎 Deploy Preview https://frontdoor-test-docs.nginx.com/previews/nginx-gateway-fabric/2701/

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.38%. Comparing base (88661c1) to head (8c4a0ba).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2701   +/-   ##
=======================================
  Coverage   89.38%   89.38%           
=======================================
  Files         110      110           
  Lines       10913    10913           
  Branches       50       50           
=======================================
  Hits         9755     9755           
  Misses       1100     1100           
  Partials       58       58           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@salonichf5 salonichf5 force-pushed the docs/rewrite-client-ip-settings branch from d119f84 to 5aa6353 Compare October 18, 2024 20:18
Copy link
Contributor

@ADubhlaoich ADubhlaoich left a comment

Choose a reason for hiding this comment

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

LGYTM, some minor nitpicks.

site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
site/content/how-to/data-plane-configuration.md Outdated Show resolved Hide resolved
@salonichf5 salonichf5 requested a review from sjberman October 21, 2024 18:33
@salonichf5 salonichf5 requested a review from bjee19 October 21, 2024 21:16
Copy link
Contributor

@bjee19 bjee19 left a comment

Choose a reason for hiding this comment

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

lgtm!

@salonichf5 salonichf5 force-pushed the docs/rewrite-client-ip-settings branch from f3a223e to 8c4a0ba Compare October 21, 2024 21:40
@salonichf5 salonichf5 merged commit cb547d6 into main Oct 21, 2024
41 checks passed
@salonichf5 salonichf5 deleted the docs/rewrite-client-ip-settings branch October 21, 2024 22:03
Copy link
Contributor

@sjberman sjberman left a comment

Choose a reason for hiding this comment

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

This was merged before I had a chance to re-review and approve. Please see my change requests.


## Configure PROXY protocol and RewriteClientIP settings

When the request is passed through multiple proxies or load balancers, the client IP is set to the IP address of the server that last handled the request. To preserve the original client IP address, you can configure `RewriteClientIP` settings in the `NginxProxy` resource. `RewriteClientIP` has the fields: _mode_, _trustedAddresses_ and _setIPRecursively_.
Copy link
Contributor

Choose a reason for hiding this comment

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

"When a request" not "When the request"

spec:
config:
rewriteClientIP:
mode: XForwardedFor
Copy link
Contributor

Choose a reason for hiding this comment

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

Part of me wonders if it makes more sense to use ProxyProtocol as the example, since that was the main use case we were targeting with this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am a little confused about that as well. I wanted to mention setIPrecursively field since it only applies to XForwardedFor

But at this point, its causing a lot of confusion so I can include both.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to provide every field in our example. Nor do we need to provide examples of both modes. Our API covers all cases, I think we just provide a basic example of the most common use case.

Comment on lines +189 to +195
trustedAddresses:
- type: CIDR
value: ":1/28"
- type: IPAddress
value: "192.68.74.28"
- type: Hostname
value: "cafe.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought, I'm not sure we need to specify all three examples here. One should be enough to get the point across. A realistic CIDR would be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just added this for user convenience to not go refer the spec and figure out types. I think we can have all fields for one example and simply it for our second example of ProxyProtocol

Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment above, this resource should ideally be something that a user could probably just plug in and use, maybe just altering the single CIDR value for their case. They shouldn't have to go in and delete every field they aren't using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the way we are thinking about this is a little different. I agree to your point too for it to be a plugin, but there would still be some editing needed to change the field value. I don't know how much of an effort difference would it be edit a field and delete two. I mentioned all types just so we could bring out most of the information in one page for the user without having to check out the spec.

But maybe that's not the right way to think about this and I'll change it to one example.

Copy link
Contributor

Choose a reason for hiding this comment

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

I get where you're coming from. We just have a pattern of our examples being realistic and not just a showcase of all of the options. And our API reference is there to specifically showcase all the options.

EOF
```

For more information, see the `NginxProxy spec` in the [API reference]({{< relref "reference/api.md" >}}).
Copy link
Contributor

@sjberman sjberman Oct 22, 2024

Choose a reason for hiding this comment

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

Instead of "For more information", I'd say "For the full configuration API".


For more information, see the `NginxProxy spec` in the [API reference]({{< relref "reference/api.md" >}}).

{{< note >}} When sending curl requests to a server expecting proxy information, use the flag `--harproxy-protocol` to avoid broken header errors. {{< /note >}}
Copy link
Contributor

Choose a reason for hiding this comment

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

--haproxy-protocol is misspelled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Documentation for PROXY protocol and rewriting client IP
5 participants