-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Rootless Nginx Wrong "remote_addr" while Rootful Nginx has correct "remote_addr" #17765
Comments
I did a little more digging and got the trivial example I posted to work properly. It seems related to functionality introduced in PR 6965 (#6965) for a bug related to "only 127.0.0.1 within containers", also having to do with throughput optimizations. A solution to the trivial example appears here. However, my actual use case involves a user-defined rootless pod with a reverse proxy and multiple web servers all on a user-defined rootless CNI network. The solution appearing here does not work in my use case. I will devise a simplified example and post an new bug report. The change is
The "no ip address using
The container can still ping itself, and the container's /etc/hosts is correct, same as above in the rootless example.
When using
|
Not really, you can even use the latest minor version, 4.4, from experimental.
That's also documented in the man page by the way:
Probably, yes. You could also try out the new network mode |
As @sbrivio-rh mentioned this is documented, for user defined networks it will not work, #8193. IMO it makes no sense to show an ip address in inspect there, this will just add confusion because the ip address not routable from anywhere beside the container netns. Each container runs their own slirp4netns instance so they cannot talk to each other in this case, you need to use forwarded host ports for that. |
Issue Description
For rootless nginx containers,
$remote_addr
takes the internal address of the container as evidenced in the container logs.For rootful nginx containers,
$remote_addr
is the correct ip address of the requesting system, as one would expect.This is a problem when using a rootless nginx container as a reverse proxy for other rootless webserver containers (the use case where I encountered the problem).
$remote_addr
it can never accurately setHTTP_X_FORWARDED_FOR
orHTTP_X_REAL_IP
to propagate to upstream webserverSteps to reproduce the issue
Steps to reproduce the issue
Rootless Example
All
podman
actions performed as a normal user oncontainerhost
This example also shows unexpected (though not necessarily related) blank "IPAddress"
Rootful Example
All
podman
actions performed as superuser oncontainerhost
Describe the results you received
Incorrect
$remote_addr
in nginx logs for rootless container instances.This also means nginx as a reverse proxy cannot be configured to pass correct
$remote_addr
viaHTTP_X_FORWARDED_FOR
orHTTP_X_REAL_IP
headers.Describe the results you expected
Correct
$remote_addr
in nginx logs for both rootless and rootful container instances.podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
I'm running
podman
in a Debian 11 x86_64 VMDebian does not maintain a recent
podman
in its repos (v3.1.x iirc)I'm using the most recent packages available to me from the OpenSuse "kubic" repo
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
The text was updated successfully, but these errors were encountered: