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

feat: automatically use X-Forwarded-For from built-in nginx #2897

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,7 @@ if [ "$1" = "runserver" ] ; then
mkdir -p /run/celery
rm -f /run/celery/beat.pid

# Generate nginx configuration
if [ -f /app/data/ssl/privkey.pem ] ; then
template=/etc/nginx/ssl.tpl
else
template=/etc/nginx/default.tpl
fi
# Parse upstream X-Forwarded-For
case "$WEBLATE_IP_PROXY_HEADER" in
HTTP_X_FORWARDED_FOR)
WEBLATE_REALIP="
Expand All @@ -277,6 +272,16 @@ set_real_ip_from 0.0.0.0/0;
WEBLATE_REALIP=""
;;
esac
# Generate nginx configuration
if [ -f /app/data/ssl/privkey.pem ] ; then
template=/etc/nginx/ssl.tpl
if [ -z "$WEBLATE_IP_PROXY_HEADER" ] ; then
# Use X-Forwarded-For from the built-in nginx
export WEBLATE_IP_PROXY_HEADER=HTTP_X_FORWARDED_FOR
fi
else
template=/etc/nginx/default.tpl
fi

export WEBLATE_REALIP
mkdir -p /tmp/nginx
Expand Down
Loading