sameersbn / sameersbn/docker-gitlab
GITLAB_TRUSTED_PROXIES is evaluated inside a yaml list item instead of expanded as an array
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 8.1k
- Forks
- 2.1k
- Avg merge
- 17h 47m
- Merged PRs (30d)
- 7
Description
In the default case, NGINX is used inside a container and has a single IP address. But multiple default proxies could be used, or, for instance, by running nginx or apache directly on the containing host. We do the latter. GITLAB_TRUSTED_PROXIES must be set to the containing host's IP address, but this can change.
Proposal:
- Change the yaml expansion to:
trusted_proxies: [ $GITLAB_TRUSTED_PROXIES ]
where GITLAB_TRUSTED_PROXIES is an array of quoted strings. This will also obviate the code in functions:
else
exec_as_git sed -i "/{{GITLAB_TRUSTED_PROXIES}}/d" ${GITLAB_CONFIG}
since
trusted_proxies: [ ]
is a valid expression.
- Use a dummy name to refer to containing host's docker-generated IP address. GITLAB_TRUSTED_PROXIES will set itself to this via the default route of the container. Example:
gitlab:
environment:
GITLAB_TRUSTED_PROXIES = dockerhost
If the container reaches the containing host by 172.18.0.5, then gitlab.yml will contain:
trusted_proxies: [ '172.18.0.5' ]
To determine this in the functions script, just use this code (test in container):
route -n |awk '$1=="0.0.0.0" { print $2 }'
Pseudo-code:
gitlab_configure_trusted_proxies() {
if [[ "${GITLAB_TRUSTED_PROXIES}" = "_dockerhost" ]]; then
GITLAB_TRUSTED_PROXIES=$( route -n |awk '$1=="0.0.0.0" { print $2 }' )
fi
echo "Configuring gitlab::trusted_proxies... for ${GITLAB_TRUSTED_PROXIES}"
update_template ${GITLAB_CONFIG} GITLAB_TRUSTED_PROXIES
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the functions script and the GitLab configuration template containing GITLAB_TRUSTED_PROXIES. Reproduce the current YAML expansion in a container, then determine how empty, multiple, and host-derived proxy values should be represented. Done means trusted proxies render as a valid array and the configuration path handles the proposed host address behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, shell
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100