-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add solrcloud proxy to support authorized requests for ckan 2.6, 2.7
- Loading branch information
Showing
6 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM nginx | ||
COPY default.conf.template entrypoint.sh templater.sh / | ||
CMD ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
server { | ||
listen 8983; | ||
server_name _; | ||
location / { | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_pass {{SOLR_URL}}; | ||
proxy_set_header Authorization "Basic {{SOLR_AUTH}}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
export SOLR_URL | ||
export SOLR_AUTH="$(echo ${SOLR_USER}:${SOLR_PASSWORD} | base64)" | ||
bash /templater.sh /default.conf.template > /etc/nginx/conf.d/default.conf | ||
echo Proxying requests from port 8983 to ${SOLR_URL} ${SOLR_USER} ${SOLR_PASSWORD} | ||
cd /etc/nginx | ||
exec nginx -g "daemon off;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# https://github.com/johanhaleby/bash-templater/commit/5ac655d554238ac70b08ee4361d699ea9954c941 | ||
readonly PROGNAME=$(basename $0) | ||
config_file="<none>" | ||
print_only="false" | ||
silent="false" | ||
[ $# -eq 0 ] && exit 1 | ||
[[ ! -f "${1}" ]] && exit 1 | ||
template="${1}" | ||
if [ "$#" -ne 0 ]; then | ||
while [ "$#" -gt 0 ] | ||
do | ||
case "$1" in | ||
-p|--print) | ||
print_only="true" | ||
;; | ||
-f|--file) | ||
config_file="$2" | ||
;; | ||
-s|--silent) | ||
silent="true" | ||
;; | ||
--) | ||
break | ||
;; | ||
-*) | ||
exit 1 | ||
;; | ||
*) ;; | ||
esac | ||
shift | ||
done | ||
fi | ||
vars=$(grep -oE '\{\{[A-Za-z0-9_]+\}\}' "${template}" | sort | uniq | sed -e 's/^{{//' -e 's/}}$//') | ||
if [[ -z "$vars" ]]; then | ||
if [ "$silent" == "false" ]; then | ||
echo "Warning: No variable was found in ${template}, syntax is {{VAR}}" >&2 | ||
fi | ||
fi | ||
if [ "${config_file}" != "<none>" ]; then | ||
if [[ ! -f "${config_file}" ]]; then | ||
echo "The file ${config_file} does not exists" >&2 | ||
echo "$usage" | ||
exit 1 | ||
fi | ||
tmpfile=`mktemp` | ||
sed -e "s;\&;\\\&;g" -e "s;\ ;\\\ ;g" "${config_file}" > $tmpfile | ||
source $tmpfile | ||
fi | ||
var_value() { | ||
eval echo \$$1 | ||
} | ||
replaces="" | ||
defaults=$(grep -oE '^\{\{[A-Za-z0-9_]+=.+\}\}' "${template}" | sed -e 's/^{{//' -e 's/}}$//') | ||
for default in $defaults; do | ||
var=$(echo "$default" | grep -oE "^[A-Za-z0-9_]+") | ||
current=`var_value $var` | ||
if [[ -z "$current" ]]; then | ||
eval $default | ||
fi | ||
replaces="-e '/^{{$var=/d' $replaces" | ||
vars="$vars | ||
$current" | ||
done | ||
vars=$(echo $vars | sort | uniq) | ||
if [[ "$print_only" == "true" ]]; then | ||
for var in $vars; do | ||
value=`var_value $var` | ||
echo "$var = $value" | ||
done | ||
exit 0 | ||
fi | ||
for var in $vars; do | ||
value=`var_value $var` | ||
if [[ -z "$value" ]]; then | ||
if [ $silent == "false" ]; then | ||
echo "Warning: $var is not defined and no default is set, replacing by empty" >&2 | ||
fi | ||
fi | ||
value=$(echo "$value" | sed 's/\//\\\//g'); | ||
replaces="-e 's/{{$var}}/${value}/g' $replaces" | ||
done | ||
escaped_template_path=$(echo $template | sed 's/ /\\ /g') | ||
eval sed $replaces "$escaped_template_path" |