gunicorn icon indicating copy to clipboard operation
gunicorn copied to clipboard

add attribute remote_addr to req object

Open zffocussss opened this issue 3 years ago • 2 comments

Hi benotic: as I come from uvicorn, and we are running gunicorn + django behind nginx,so I think it is more convenient for people to get the remote address with request.remote_addr than the raw REMOTE_ADDR.I hope you consider my suggestions and approve it. PS: I use the pre_request to add some request headers based on the remote address.Uvicorn also have a request object,I can get the client ip with request.client.host.

zffocussss avatar Jul 13 '22 07:07 zffocussss

DO you have any example of usage for it?

benoitc avatar Aug 06 '22 16:08 benoitc

@zffocussss ?

benoitc avatar Aug 25 '22 12:08 benoitc

@zffocussss ?

sorry to not reply to you in time.as I forgot it probably.In my opinion,it is just a shortcut which is useful for people which want get the real client ip directly.

zffocussss avatar Oct 17 '22 04:10 zffocussss

Should e3336cfa9fe6dba623276155f48208c6d118d937 have been merged instead of c9d01c801967596f66636cfc0c47660339d32631 here?

jayaddison avatar Nov 29 '22 00:11 jayaddison

Should e3336cf have been merged instead of c9d01c8 here?

commit https://github.com/benoitc/gunicorn/commit/c9d01c801967596f66636cfc0c47660339d32631 is enough,as I do not touch any codes but this tiny snippet

zffocussss avatar Dec 02 '22 08:12 zffocussss

Ok, thanks @zffocussss. c9d01c801967596f66636cfc0c47660339d32631 seems incomplete though -- it does not include unit tests. Could you check?

jayaddison avatar Dec 08 '22 13:12 jayaddison

@benoitc maybe worth reverting this (or merging #2896) this until the feature can be completed?

jayaddison avatar Dec 11 '22 23:12 jayaddison

Hi. Unfortunately, this PR probably broke the ability to bind to unix sockets. See #2904.

TomiBelan avatar Dec 18 '22 14:12 TomiBelan

Bug #2904 is fixed in master. The broken commit c9d01c801967596f66636cfc0c47660339d32631 (one half of this PR) was reverted in 30baeebf337850a7ce3cb8099ffa248cef5831ef (PR #2927) by @benoitc and @samypr100.

I wonder if they saw my comment, or they found the problem independently...

For what it's worth, 69bf1d0cf44abffeeb469d4c36e1ff978b6e5769 (the second half of this PR) is still in master -- on its own, useless, but harmless.

TomiBelan avatar Feb 17 '23 18:02 TomiBelan