B2Bitcoin / beBOP

Marvelous p2p bitcoin-based online sales platform
https://be-bop.io
GNU Affero General Public License v3.0
14 stars 3 forks source link

☢️ VPS at OVH overwrite the user IP country with the server IP country #1350

Closed Tirodem closed 3 days ago

Tirodem commented 2 months ago

Currently, on be-BOP, when you go to /checkout and there's an address form, the country is pre-filled with visitor's country IP (except for https://github.com/B2Bitcoin/beBOP/issues/1186 to keep in mind). On local machines and on Nodl cloud env, the behavior is good. On OVH VPS Starter, the displayed country is always "French", even being in Switzerland physically with a confirmed swiss IP (by ip2location), or in USA through a VPN. For VAT purpose, having the IP wrongly detected is bad. We need to check.

coyotte508 commented 2 months ago

It depends on the reverse proxy (apache, nginx) and the forwarded headers.

When placing the beBOP behind a reverse proxy, to get your user's IPs, you will need to set the ADDRESS_HEADER to X-Forwaded-For and the XFF_DEPTH header to 1 (or appropriate value depending on your config) in the environment.

You also need to configure nginx or apache to correctly send the X-Forwarded-For header

Tirodem commented 2 months ago

Oh, yeah, good guess, I missed that. I'll try later tonight 👌

Tirodem commented 2 months ago

It's kinda funny, with this in my .env.local :

ADDRESS_HEADER=X-Forwarded-For
XFF_DEPTH=1

When I do this (after a pm2 tasks reset) pm2 start --name bebop --update-env build/index.js -f Or this pm2 restart all --update-env It doesn't work But if I don't put the values in my .env.local then use this command : ADDRESS_HEADER=X-Forwarded-For XFF_DEPTH=1 pm2 start --name bebop --update-env build/index.js -f It now works (being on USA through Cyberghost VPN) : image So I'll go with it right now but did I miss something for the .env.local update ?

And, for documentation issues, we have some X-Forwaded-For instead of X-Forwarded-For in it.

BTW, I'm unlocked on my pilots.

coyotte508 commented 2 months ago

yes it probably is tricky to make it work with .env.local for those two variables, setting them in the environment directly is probably best