HAproxy pfsense

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
manuroma
Posts: 12
Joined: Fri Jan 15, 2021 1:06 pm

HAproxy pfsense

Post by manuroma »

hi all, I have let's say a need, I would like to use my HAProxy installed on pfsense to access ZM, but I can't get it to work, I have a ddns and a public certificate. The same way I use it for home automation and it works well, surely I am missing some configuration but maybe if someone has this type of configuration you can give me some advice.
manuroma
Posts: 12
Joined: Fri Jan 15, 2021 1:06 pm

Re: HAproxy pfsense

Post by manuroma »

Now i test the nginx proxy manager (docker install) and Homeassistant work fine but ZM open the loginpage without grafic
zoneloginerr.PNG
zoneloginerr.PNG (17.02 KiB) Viewed 765 times
and when i login stuck on this page
zoneloginerr2.PNG
zoneloginerr2.PNG (6.84 KiB) Viewed 765 times
i see a lot of guide for configure and modify my includes/server.php

Code: Select all

<?php
namespace ZM;
require_once('database.php');
require_once('Object.php');


class Server extends ZM_Object {
  protected static $table = 'Servers';

  protected $defaults = array(
    'Id'                   => null,
    'Name'                 => '',
    'Protocol'             => '',
    'Hostname'             => '',
    'Port'                 => null,
    'PathToIndex'          => null,
    'PathToZMS'            => ZM_PATH_ZMS,
    'PathToApi'            => '/zm/api',
    'zmaudit'              => 1,
    'zmstats'              => 1,
    'zmtrigger'            => 0,
    'zmeventnotification'  => 0,
  );

  public static function find( $parameters = array(), $options = array() ) {
    return ZM_Object::_find(get_class(), $parameters, $options);
  }

  public static function find_one( $parameters = array(), $options = array() ) {
    return ZM_Object::_find_one(get_class(), $parameters, $options);
  }

  public function Hostname( $new = null ) {
    if ( $new != null )
      $this->{'Hostname'} = $new;

    if ( isset( $this->{'Hostname'}) and ( $this->{'Hostname'} != '' ) ) {
      return $this->{'Hostname'};
    } else if ( $this->Id() ) {
      return $this->{'Name'};
    }
    # This theoretically will match ipv6 addresses as well
    if ( preg_match( '/^(\[[[:xdigit:]:]+\]|[^:]+)(:[[:digit:]]+)?$/', $_SERVER['HTTP_HOST'], $matches ) ) {
      return $matches[1];
    }

    $result = explode(':', $_SERVER['HTTP_HOST']);
    return $result[0];
  }

  public function Protocol( $new = null ) {
    if ( $new != null )
      $this->{'Protocol'} = $new;

    if ( isset($this->{'Protocol'}) and ( $this->{'Protocol'} != '' ) ) {
      return $this->{'Protocol'};
    }

        $headers = apache_request_headers();

        if (isset($headers['X-Forwarded-Proto'])) {
		            return($headers['X-Forwarded-Proto']);
			        }

    return  (
          ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' )
          or
          ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) )
        ) ? 'https' : 'http';
  }

  public function Port( $new = '' ) {
    if ( $new != '' )
      $this->{'Port'} = $new;

    if ( isset($this->{'Port'}) and $this->{'Port'} ) {
      return $this->{'Port'};
    }
    
       $headers = apache_request_headers();

       if (isset($headers['X-Forwarded-Port'])) {
	              return($headers['X-Forwarded-Port']);
		         }


    return $_SERVER['SERVER_PORT'];
  }

  public function PathToZMS( $new = null ) {
    if ( $new != null )
      $this->{'PathToZMS'} = $new;
    if ( $this->Id() and $this->{'PathToZMS'} ) {
      return $this->{'PathToZMS'};
    } else {
      return ZM_PATH_ZMS;
    }
  }

  public function UrlToZMS( $port = null ) {
    return $this->Url($port).$this->PathToZMS();
  }

	public function Url( $port = null ) {
    if ( ! ( $this->Id() or $port ) ) {
      # Don't specify a hostname or port, the browser will figure it out
      return '';
    }

    $url = $this->Protocol().'://';
		$url .= $this->Hostname();
    if ( $port ) {
      $url .= ':'.$port;
    } else {
      $url .= ':'.$this->Port();
    }
    return $url;
	}

  public function PathToIndex( $new = null ) {
    if ( $new != null )
      $this->{'PathToIndex'} = $new;

    if ( isset($this->{'PathToIndex'}) and $this->{'PathToIndex'} ) {
      return $this->{'PathToIndex'};
    }
    // We can't trust PHP_SELF to not include an XSS vector. See note in skin.js.php.
    return preg_replace('/\.php.*$/i', '.php', $_SERVER['PHP_SELF']);
  }

  public function UrlToIndex( $port=null ) {
    return $this->Url($port).$this->PathToIndex();
  }
  public function UrlToApi( $port=null ) {
    return $this->Url($port).$this->PathToApi();
  }
  public function PathToApi( $new = null ) {
    if ( $new != null )
      $this->{'PathToApi'} = $new;

    if ( isset($this->{'PathToApi'}) and $this->{'PathToApi'} ) {
      return $this->{'PathToApi'};
    }
    return '/zm/api';
  }
} # end class Server
?>
now I don't know what to do, I don't know where the problem is, what config to modify.
Post Reply