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

Get user real IP when running BOCA with a reverse proxy #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rlaiola
Copy link
Contributor

@rlaiola rlaiola commented Oct 6, 2023

Reference Issues

The proposed approach addresses the issue reported at #38.

What does this implement/fix?

This pull request includes a code fix to get the real IP of the user when running BOCA with a reverse proxy. If REMOTE_ADDR belongs to a list of trusted proxies (BOCA_TRUSTED_PROXIES env var), then BOCA should consider that the real user IP is in HTTP_X_FORWARDED_FOR.

How to test it?

git clone --branch test_fix_getip_proxy https://github.com/rlaiola/boca.git
cd boca
# Launch application (it may take a while)
BOCA_TRUSTED_PROXIES=192.168.0.100 docker compose up -d
# Open a web browser and visit the URL http://localhost/boca.
# First, create and activate a BOCA contest (user: system | password: boca).
# Then, login as admin (user: admin | password: boca).
# Visit the users' page to see that the admin IP is NOT 192.168.0.100 (the proxy IP)
# To stop the application:
docker compose down

Other Comments

Feel free to suggest other approaches to address the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant