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

update upstreams to format ipv6 adddress for nginx plus #2339

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

salonichf5
Copy link
Contributor

Proposed changes

Problem: Users want to have IPv6 upstreams correctly formatted when using NGINX Plus with NGF.

Solution: Adds a fix to update IP format based on endpoint type.

Testing: Manual Testing of installing NGF with NGINX Plus and verifying config for IPv6 services.

nginx.conf



upstream default_tea_80 {
    random two least_conn;
    zone default_tea_80 1m;

    server 192.168.194.32:8080;
}

upstream default_coffee_80 {
    random two least_conn;
    zone default_coffee_80 1m;

    server [fd07:b51a:cc66:a::1f]:8080;
}

Curl request using IPv6 address for IPv6 service

curl -v --resolve cafe.example.com:$GW_PORT:$GW_IPv6  http://cafe.example.com:$GW_PORT/coffee
* Added cafe.example.com:8080:::1 to DNS cache
* Hostname cafe.example.com was found in DNS cache
*   Trying [::1]:8080...
* Connected to cafe.example.com (::1) port 8080
> GET /coffee HTTP/1.1
> Host: cafe.example.com:8080
> User-Agent: curl/8.4.0
> Accept: */*
>
Handling connection for 8080
< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 07 Aug 2024 04:22:19 GMT
< Content-Type: text/plain
< Content-Length: 170
< Connection: keep-alive
< Expires: Wed, 07 Aug 2024 04:22:18 GMT
< Cache-Control: no-cache
<
Server address: fd07:b51a:cc66:a::1f:8080
Server name: coffee-6b8b6d6486-whg5r
Date: 07/Aug/2024:04:22:19 +0000
URI: /coffee
Request ID: cb0e68d5b46bb6876d36d3ece0447724

Curl request using IPv4 address for IPv6 service

curl -v --resolve cafe.example.com:$GW_PORT:$GW_IP  http://cafe.example.com:$GW_PORT/coffee
* Added cafe.example.com:8080:127.0.0.1 to DNS cache
* Hostname cafe.example.com was found in DNS cache
*   Trying 127.0.0.1:8080...
* Connected to cafe.example.com (127.0.0.1) port 8080
> GET /coffee HTTP/1.1
> Host: cafe.example.com:8080
> User-Agent: curl/8.4.0
> Accept: */*
>
Handling connection for 8080
< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 07 Aug 2024 04:22:09 GMT
< Content-Type: text/plain
< Content-Length: 170
< Connection: keep-alive
< Expires: Wed, 07 Aug 2024 04:22:08 GMT
< Cache-Control: no-cache
<
Server address: fd07:b51a:cc66:a::1f:8080
Server name: coffee-6b8b6d6486-whg5r
Date: 07/Aug/2024:04:22:09 +0000
URI: /coffee
Request ID: 34eeff12748cdac848d5a8db5c1345b4

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 #2338

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 a review from a team as a code owner August 7, 2024 04:29
@github-actions github-actions bot added the bug Something isn't working label Aug 7, 2024
Copy link

codecov bot commented Aug 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.07%. Comparing base (2cb44de) to head (4b60de0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2339   +/-   ##
=======================================
  Coverage   88.07%   88.07%           
=======================================
  Files          97       97           
  Lines        6993     6996    +3     
  Branches       50       50           
=======================================
+ Hits         6159     6162    +3     
  Misses        777      777           
  Partials       57       57           

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

@salonichf5 salonichf5 enabled auto-merge (squash) August 7, 2024 16:01
@salonichf5 salonichf5 merged commit 5affa40 into nginxinc:main Aug 7, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Format endpoints based off of IP family when dynamically updating upstream servers through the N+ API
3 participants