Skip to content

Commit 3a385fc

Browse files
committed
feat(nginx): add support for proxy_pass_header directive via NGINX_PROXY_PASS_HEADER_*
fixes #206
1 parent f958365 commit 3a385fc

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ This web user interface uses [Riot](https://github.com/Riot/riot) the react-like
4646
- Multi arch support in history page (see [#130](https://github.com/Joxit/docker-registry-ui/issues/130) and [#134](https://github.com/Joxit/docker-registry-ui/pull/134))
4747
- Set a list of default registries with `DEFAULT_REGISTRIES` (see [#219](https://github.com/Joxit/docker-registry-ui/pull/219)).
4848
- Desactivate add and remove regisitries with `READ_ONLY_REGISTRIES` (see [#219](https://github.com/Joxit/docker-registry-ui/pull/219)).
49-
- Filter images and tags with a search bar. You can select the search bar with the shortcut `CRTL` + `F` or `F3`. When the search bar is already focused, the shortcut will fallback to the default behavior (see [#213](https://github.com/Joxit/docker-registry-ui/issues/213)).
49+
- Filter images and tags with a search bar. You can select the search bar with the shortcut `CRTL` + `F` or `F3`. When the search bar is already focused, the shortcut will fallback to the default behavior (see [#213](https://github.com/Joxit/docker-registry-ui/issues/213)).
50+
- **Forward** custom header to your backend registry via environment variable and file via `NGINX_PROXY_PASS_HEADER_*` (see [#206](https://github.com/Joxit/docker-registry-ui/pull/206)).
5051

5152
## FAQ
5253

@@ -90,7 +91,8 @@ Some env options are available for use this interface for **only one server**.
9091
- `CATALOG_ELEMENTS_LIMIT`: Limit the number of elements in the catalog page. (default: `100000`).
9192
- `SINGLE_REGISTRY`: Remove the menu that show the dialogs to add, remove and change the endpoint of your docker registry. (default: `false`).
9293
- `NGINX_PROXY_PASS_URL`: Update the default Nginx configuration and set the **proxy_pass** to your backend docker registry (this avoid CORS configuration). This is usually the name of your registry container in the form `http://registry:5000`.
93-
- `NGINX_PROXY_HEADER_*`: Update the default Nginx configuration and set **custom headers** for your backend docker registry. Only when `NGINX_PROXY_PASS_URL` is used.
94+
- `NGINX_PROXY_HEADER_*`: Update the default Nginx configuration and **set custom headers** for your backend docker registry. Only when `NGINX_PROXY_PASS_URL` is used.
95+
- `NGINX_PROXY_HEADER_*`: Update the default Nginx configuration and **forward custom headers** to your backend docker registry. Only when `NGINX_PROXY_PASS_URL` is used.
9496
- `DEFAULT_REGISTRIES`: List of comma separated registry URLs (e.g `http://registry.example.com,http://registry:5000`), available only when `SINGLE_REGISTRY=false`. (default: ` `).
9597
- `READ_ONLY_REGISTRIES`: Desactivate dialog for remove and add new registries, available only when `SINGLE_REGISTRY=false`. (default: `false`).
9698

bin/entrypoint

+17
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,25 @@ get_nginx_proxy_headers() {
3232
done
3333
}
3434

35+
get_nginx_proxy_pass_headers() {
36+
(
37+
env &&
38+
if [ -f "/etc/nginx/.env" ]; then
39+
cat /etc/nginx/.env
40+
# Force new line
41+
echo ""
42+
fi
43+
) | while read e; do
44+
if [ -n "$(echo $e | grep -o '^NGINX_PROXY_PASS_HEADER_')" ]; then
45+
key=$(echo ${e%%=*} | sed 's/^NGINX_PROXY_PASS_HEADER_//' | sed 's/_/-/g')
46+
echo -n "proxy_pass_header \"${key}\"; "
47+
fi
48+
done
49+
}
50+
3551
if [ -n "${NGINX_PROXY_PASS_URL}" ] ; then
3652
sed -i "s,\${NGINX_PROXY_PASS_URL},${NGINX_PROXY_PASS_URL}," /etc/nginx/conf.d/default.conf
3753
sed -i "s^\${NGINX_PROXY_HEADERS}^$(get_nginx_proxy_headers)^" /etc/nginx/conf.d/default.conf
54+
sed -i "s^\${NGINX_PROXY_PASS_HEADERS}^$(get_nginx_proxy_pass_headers)^" /etc/nginx/conf.d/default.conf
3855
sed -i "s,#!,," /etc/nginx/conf.d/default.conf
3956
fi

nginx/default.conf

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ server {
2727
#! return 404;
2828
#! }
2929
#! ${NGINX_PROXY_HEADERS}
30+
#! ${NGINX_PROXY_PASS_HEADERS}
3031
#! proxy_pass ${NGINX_PROXY_PASS_URL};
3132
#! }
3233

0 commit comments

Comments
 (0)