scline / docker-cacti

Cacti version 1+ under Docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add CACTI_URL_PATH

xbolshe opened this issue · comments

Now $url_path = '/cacti/' is hardcoded in config.php. And there is no possibility to change it via an environment variable.
My proposal is to add CACTI_URL_PATH to have a possibility to change url_path. It is useful for Kubernetes with Ingress controller.

$url_path = '/cacti/';

By chance do you know what values need to change in the HTTP config file? Example if the /cacti/ URL was changed to /test/:

<VirtualHost *:80>
	DocumentRoot    /cacti
	Alias           /cacti          /cacti
        RedirectMatch   ^/$             /cacti
        <Directory "/cacti">
                Require all granted
        </Directory>
</VirtualHost>


<VirtualHost *:443>
	DocumentRoot            /cacti
	Alias                   /cacti          /cacti
        RedirectMatch           ^/$             /cacti
        <Directory "/cacti">
                Require all granted
        </Directory>
        SSLEngine On
        SSLCertificateFile      /etc/ssl/certs/cacti.crt
        SSLCertificateKeyFile   /etc/ssl/certs/cacti.key
</VirtualHost>

In my understanding,

<VirtualHost *:80>
	DocumentRoot    /cacti                         <--- folder, do not change
	Alias           /cacti          /cacti                 <----- change first, 2nd is a folder
        RedirectMatch   ^/$             /cacti         <--- URL, need to use CACTI_URL_PATH
        <Directory "/cacti">                               <--- folder, do not change
                Require all granted
        </Directory>
</VirtualHost>


<VirtualHost *:443>
	DocumentRoot            /cacti                   <--- folder, do not change
	Alias                   /cacti          /cacti            <----- change first, 2nd is a folder
        RedirectMatch           ^/$             /cacti     <--- URL, need to use CACTI_URL_PATH
        <Directory "/cacti">                                    <--- folder, do not change
                Require all granted
        </Directory>
        SSLEngine On
        SSLCertificateFile      /etc/ssl/certs/cacti.crt
        SSLCertificateKeyFile   /etc/ssl/certs/cacti.key
</VirtualHost>

More information:
https://httpd.apache.org/docs/2.4/mod/mod_alias.html
https://httpd.apache.org/docs/2.4/mod/core.html#documentroot
https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirectmatch

Ah perfect, I had some things backwards thank you so much!

Give the 1.2.14 branch a shot when you can, example docker-compose where the URL is now http://<cacti_ip>/xbolshe

version: '2'
services:


  cacti:
    image: "smcline06/cacti:1.2.14"
    container_name: cacti
    domainname: example.com
    hostname: cacti
    ports:
      - "80:80"
      - "443:443"
    environment:
      - DB_NAME=cacti_master
      - DB_USER=cactiuser
      - DB_PASS=cactipassword
      - DB_HOST=db
      - DB_PORT=3306
      - DB_ROOT_PASS=rootpassword
      - CACTI_URL_PATH=xbolshe
      - INITIALIZE_DB=1
      - TZ=America/Los_Angeles
    volumes:
      - cacti-data:/cacti
      - cacti-spine:/spine
      - cacti-backups:/backups
    links:
      - db


  db:
    image: "mariadb:10.3"
    container_name: cacti_db
    domainname: example.com
    hostname: db
    ports:
      - "3306:3306"
    command:
      - mysqld
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --max_connections=200
      - --max_heap_table_size=128M
      - --max_allowed_packet=32M
      - --tmp_table_size=128M
      - --join_buffer_size=128M
      - --innodb_buffer_pool_size=1G
      - --innodb_doublewrite=ON
      - --innodb_flush_log_at_timeout=3
      - --innodb_read_io_threads=32
      - --innodb_write_io_threads=16
      - --innodb_buffer_pool_instances=9
      - --innodb_file_format=Barracuda
      - --innodb_large_prefix=1
      - --innodb_io_capacity=5000
      - --innodb_io_capacity_max=10000
    environment:
      - MYSQL_ROOT_PASSWORD=rootpassword
      - TZ=America/Los_Angeles
    volumes:
      - cacti-db:/var/lib/mysql


volumes:
  cacti-db:
  cacti-data:
  cacti-spine:
  cacti-backups:

Yes, CACTI_URL_PATH works well starting from Cacti installation in smcline06/cacti:1.2.14.

Thank you, merged to master. latest will now have these changes.