#1 2018-05-14 09:15:55

greybeard
Trusted Member
Registered: 2015-01-09
Posts: 11

HAProxy script error debian 9 at GestionDBI les vps

This error has been reported previously for debian 8 in this thread https://forum.lowendspirit.com/viewtopic.php?id=3424




Believe the error is present with debian 9 as well.

./NATreverseProxy.sh proxy list
curl: (6) Could not resolve host: .5

As far as I can debug the error is in the awk statement that extracts the venet ip using ifconfig. It returns an empty string with the tralling constant '.5' which doesn't resolve.

near the start of proxy.sh

# Setting of basic variables
# HOSTNODE_ADDRESS=localhost:8000
HOSTNODE_ADDRESS="$(ifconfig venet0:0 | awk -F: '/inet addr:/ { split($2,a,"."); print a[1]"."a[2]"."a[3]; }').5"

for reference o/p of ifconfig venet0:0 (IP redacted)

ifconfig venet0:0
venet0:0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP>  mtu 1500
        inet xxx.xx.xx.xx  netmask 255.255.255.255  broadcast xxx.xx.xx.xx  destination xx.xx.xx.xx
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 0  (UNSPEC)

Offline

#2 2018-09-18 17:01:21

lupine
Trusted Member
Registered: 2017-02-16
Posts: 22

Re: HAProxy script error debian 9 at GestionDBI les vps

Same problem here. Hope there is a solution.

Offline

#3 2018-09-22 17:55:31

WSS
Trusted Member
Registered: 2016-12-22
Posts: 416

Re: HAProxy script error debian 9 at GestionDBI les vps

I posted a workaround for iptools2 here:  https://forum.lowendspirit.com/viewtopi … 812#p20812

I haven't tested this outside of making sure the code works; I haven't setup any proxies with my GDBI services.

#!/bin/bash

# Function definition helper
define(){ IFS='\n' read -r -d '' ${1} || true; }

# Setting of basic variables
# HOSTNODE_ADDRESS=localhost:8000
# Unofficial iptools2 patch/wss
$FOUND1=$(which ifconfig)
$FOUND2=$(which ip)

if [ $FOUND1 -ne "" ]; then
  HOSTNODE_ADDRESS="$(ifconfig venet0:0 | awk -F: '/inet\s[:a-z?]/ { split($2,a,"."); print a[1]"."a[2]"."a[3]; }').5"
elif
  [ $FOUND2 -ne "" ]; then
  #IFACE=$(ip ro | awk '/default/ {print $5}'} #Doesn't work, since VZ6 uses venet0:0 for actual IP
  HOSTNODE_ADDRESS="$(ip addr list venet0:0 | sed s,'.*inet\s,,g' | awk -F: '/global/ { split($1,a,"."); print a[1]"."a[2]"."a[3]; }').5"
else
  echo "Sorry, I can't find the iptools scripts."
  exit 255
fi

define HELP <<'EOT'
 _                  _____           _ ____             _ _   
| |    _____      _| ____|_ __   __| / ___| _ __  _ __(_) |_ 
| |   / _ \ \ /\ / /  _| | '_ \ / _` \___ \| '_ \| '__| | __|
| |__| (_) \ V  V /| |___| | | | (_| |___) | |_) | |  | | |_ 
|_____\___/ \_/\_/ |_____|_| |_|\__,_|____/| .__/|_|  |_|\__|
                                           |_|               
NAT Reverse Proxy Command Line Interface, version 1.1.1 (19/02/18)

Usage: ./NATreverseProxy [verb] 

Verbs:
list: 		list proxy entries
add: 		add proxy entry
addCustomSSL: 	add proxy entry w/ custom SSL
export:		export proxy keys and certs
reissue: 	reissue proxy entry
remove: 	remove proxy entry
help: 		this help message

Copyright (c) 2016-2018 Gestion David Boisvert Informatique.
All rights reserved.
EOT

define PROXY_ADD_HELP <<'EOT'
Usage:
./NATreverseProxy add <hostname>

As for customSSL, you're required to provide the file path to your private key and full certificate chain, as per the following:
./NATreverseProxy addCustomSSL <hostname> <private key> <fullchain>

Note: Usage of customSSL would result to the wipeout of previous Let's Encrypt certificates - use with caution!
EOT

define PROXY_REMOVE_HELP <<'EOT'
Usage:
./NATreverseProxy remove <hostname>

Doing so will delete the domain from our system, so it will not be proxied anymore!
EOT

define PROXY_EXPORT_HELP <<'EOT'
Usage:
./NATreverseProxy export <hostname> <type>

hostname: your hostname that youy have already proxied through our system
type: "key" or "cert"
EOT

if [ "$1" = "list" ]
then
	curl $HOSTNODE_ADDRESS/list

elif [ "$1" = "view" ]
then
	curl -X POST -F "domain=$3" -k $HOSTNODE_ADDRESS/view

elif [ "$1" = "add" ]
then
	if [ ! "$2" = '' ]
	then
		echo "Sending request to add $2..."
		curl -X POST -F "domain=$2" -k $HOSTNODE_ADDRESS/add

	else
		printf "$PROXY_ADD_HELP"
	fi

elif [ "$1" = "addCustomSSL" ]
then
	if [ ! "$2" = '' ]
	then
		KEY=$3
		CERT=$4

		cat <<-EOT > .GDBIpostfile
		--FILEUPLOAD
		Content-Disposition: form-data; name="domain"

		$2
		--FILEUPLOAD
		Content-Disposition: form-data; name="type"

		customSSL
		--FILEUPLOAD
		Content-Disposition: form-data; name="key"

		$(cat $KEY)
		--FILEUPLOAD
		Content-Disposition: form-data; name="cert"

		$(cat $CERT)
		--FILEUPLOAD--

		EOT

		wget -O- -q --header="Content-type: multipart/form-data boundary=FILEUPLOAD" --post-file .GDBIpostfile $HOSTNODE_ADDRESS/add
		rm -rf .GDBIpostfile

	else
		printf "$PROXY_ADD_HELP"
	fi

elif [ "$1" = "export" ]
then
	if [ ! "$2" = '' ] && [ ! "$3" = '' ]
	then
		cat <<-EOT > .GDBIpostfile

		--FILEUPLOAD
		Content-Disposition: form-data; name="domain"

		$2
		--FILEUPLOAD
		Content-Disposition: form-data; name="type"

		$3
		--FILEUPLOAD

		EOT

		wget -O- -q --header="Content-type: multipart/form-data boundary=FILEUPLOAD" --post-file .GDBIpostfile $HOSTNODE_ADDRESS/export
		rm -rf .GDBIpostfile

	else
		printf "$PROXY_EXPORT_HELP"
	fi

elif [ "$1" = "remove" ]
then
	if [ ! "$2" = '' ]
	then
		echo "Sending request to remove $2..."
		curl -X POST -F "domain=$2" -k $HOSTNODE_ADDRESS/remove

	else
		printf "$PROXY_REMOVE_HELP"
	fi

else
	printf "$HELP"
fi

Last edited by WSS (2018-09-22 18:09:12)


RbyeR4Nm.png

Offline

#4 2018-09-22 18:10:38

mikho
Low End Mod
From: Hell and gore == Sweden
Registered: 2013-03-02
Posts: 1,647
Website

Re: HAProxy script error debian 9 at GestionDBI les vps

Why not set
HOSTNODE_ADDRESS= to your IP address with the lst octet changed to .5 ?

I haven’t read the code but from what is paster here, I guess that would do it??

Offline

#5 2018-09-22 20:35:46

WSS
Trusted Member
Registered: 2016-12-22
Posts: 416

Re: HAProxy script error debian 9 at GestionDBI les vps

That'd work perfectly fine.  It's not automagical, though!


RbyeR4Nm.png

Offline

#6 2018-09-22 20:36:11

WSS
Trusted Member
Registered: 2016-12-22
Posts: 416

Re: HAProxy script error debian 9 at GestionDBI les vps

Eh, could always parse $1, too, if you get it wrong, then it still breaks. big_smile


RbyeR4Nm.png

Offline

#7 2018-09-22 20:49:04

mikho
Low End Mod
From: Hell and gore == Sweden
Registered: 2013-03-02
Posts: 1,647
Website

Re: HAProxy script error debian 9 at GestionDBI les vps

WSS wrote:

That'd work perfectly fine.  It's not automagical, though!

Change it once, run it many times..... who cares when it works?

Offline

#8 2018-09-22 20:52:58

WSS
Trusted Member
Registered: 2016-12-22
Posts: 416

Re: HAProxy script error debian 9 at GestionDBI les vps

mikho wrote:
WSS wrote:

That'd work perfectly fine.  It's not automagical, though!

Change it once, run it many times..... who cares when it works?

I was just bored, and know that Debian 9 has moved to iptools2; I forgot the syntatical change in iptools1, so I just kind of bodged that.


RbyeR4Nm.png

Offline

Board footer

Powered by FluxBB