Browse Source

base64 fix

master
gsd 3 weeks ago
parent
commit
2a5c3cbda3
  1. 2
      .gitignore
  2. 6
      docker-compose.yaml
  3. 26
      entrypoint.sh

2
.gitignore

@ -1 +1 @@
.htpasswd
.env

6
docker-compose.yaml

@ -15,10 +15,8 @@ services:
restart: unless-stopped
#COMBO | base auth for this instance
#GATEWAY | first gateway without pass words
environment:
- COMBO=test:test;test1:test1
- GATEWAY=p_gw:9091;p_gw:9091|user:pass;p_gw:9091|user:pass
- PORT=9100
env_file:
- .env
#volumes:
# - $PWD/srv.conf:/etc/nginx/conf.d/srv.conf:ro
# - $PWD/.htpasswd:/etc/nginx/.htpasswd:ro

26
entrypoint.sh

@ -3,11 +3,11 @@
#htpasswd part
rm /etc/nginx/.htpasswd || echo "cleared"
touch /etc/nginx/.htpasswd
USERS_SPLIT=$(echo $COMBO | tr ";" "\n")
USERS_SPLIT=$(echo -n $COMBO | tr ";" "\n")
for USER in $USERS_SPLIT
do
USERNAME=$(echo $USER | cut -d ":" -f 1)
PASSWORD=$(echo $USER | cut -d ":" -f 2)
USERNAME=$(echo -n $USER | cut -d ":" -f 1)
PASSWORD=$(echo -n $USER | cut -d ":" -f 2)
htpasswd -b /etc/nginx/.htpasswd $USERNAME $PASSWORD
done
@ -15,14 +15,14 @@ done
#gateway_0 is main
rm /etc/nginx/conf.d/srv.conf || echo "cleared"
touch /etc/nginx/conf.d/srv.conf
GATEWAYS_SPLIT=$(echo $GATEWAY | tr ";" "\n")
GATEWAYS_SPLIT=$(echo -n $GATEWAY | tr ";" "\n")
COUNTER=0
for GATEWAY in $GATEWAYS_SPLIT
do
cat <<EOT >> /etc/nginx/conf.d/srv.conf
upstream gateway_$COUNTER {
server $(echo $GATEWAY | cut -d "|" -f 1);
server $(echo -n $GATEWAY | cut -d "|" -f 1);
}
EOT
@ -34,12 +34,19 @@ cat <<EOT >> /etc/nginx/conf.d/srv.conf
server {
listen 0.0.0.0:$PORT;
server_name __;
proxy_buffering off;
client_body_buffer_size 10M;
client_max_body_size 10M;
location / {
proxy_pass http://gateway_0;
}
location /metrics {
auth_basic "Pushgateway server authentication";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://gateway_0;
EOT
#mirror redirect
@ -75,14 +82,13 @@ for GATEWAY in $GATEWAYS_SPLIT
do
if [ $COUNTER -gt 0 ]; then
cat <<EOT >> /etc/nginx/conf.d/srv.conf
location = /mirror_$COUNTER {
internal;
rewrite /.* \$request_uri break;
proxy_pass http://gateway_$COUNTER;
proxy_set_header X-Is-Mirror 'yes';
proxy_pass_header X-Is-Mirror;
proxy_set_header Authorization "Basic $(echo $GATEWAY | cut -d "|" -f 2 | base64)";
proxy_pass_header Authorization;
proxy_set_header Authorization "Basic $(echo -n $GATEWAY | cut -d "|" -f 2 | base64)";
limit_except POST {
deny all;

Loading…
Cancel
Save