Homebox

Contenuti

Homebox#

Vedi anche

  • Home - Homebox [1]

  • GitHub - hay-kot/homebox: Homebox is the inventory and organization system built for the Home User [2]

  • Apache/2.4.52 (Ubuntu) VHOST/Reverse Proxy Help · Issue #707 · hay-kot/homebox · GitHub [3]

Homebox is a free and open source inventory and organization system.

Installation#

  1. follow the Docker instructions

  2. create the jobs directories. See reference

    mkdir -p /home/jobs/scripts/by-user/root/docker/homebox
    cd /home/jobs/scripts/by-user/root/docker/homebox
    
  3. create a Docker compose file

    /home/jobs/scripts/by-user/root/docker/homebox/docker-compose.yml#
    version: "3.4"
    
    services:
      homebox:
        image: ghcr.io/hay-kot/homebox:v0.10.3
        container_name: homebox
        restart: always
        environment:
        - HBOX_LOG_LEVEL=info
        - HBOX_LOG_FORMAT=text
        - HBOX_WEB_MAX_UPLOAD_SIZE=10
        - HBOX_MAILER_HOST=${MAILER_FQDN}
        - HBOX_MAILER_PORT=465
        - HBOX_MAILER_USERNAME=homebox
        - HBOX_MAILER_PASSWORD=${MAILER_PASSWORD}
        - HBOX_MAILER_FROM=Homebox <homebox@${FQDN}>
        volumes:
          - ${DATA_PATH}:/data/
        ports:
          - 127.0.0.1:4014:7745
    
    volumes:
       homebox-data:
         driver: local
    

    Nota

    Replace MAILER_FQDN, MAILER_PASSWORD, and DATA_PATH with appropriate values.

  4. create a Systemd unit file. See also the Docker compose services section

    /home/jobs/services/by-user/root/docker-compose.homebox.service#
    [Unit]
    Requires=docker.service
    Requires=network-online.target
    After=docker.service
    After=network-online.target
    
    ## Run
    ## docker-compose up --detach --force-recreate
    ## to reload configuration.
    
    [Service]
    # https://community.hetzner.com/tutorials/docker-compose-as-systemd-service
    Type=simple
    WorkingDirectory=/home/jobs/scripts/by-user/root/docker/homebox
    
    ExecStart=/usr/bin/docker-compose up --remove-orphans
    ExecStop=/usr/bin/docker-compose down --remove-orphans
    
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  5. fix the permissions

    chmod 700 /home/jobs/scripts/by-user/root/docker/homebox
    chmod 700 -R /home/jobs/services/by-user/root
    
  6. run the deploy script

  7. add a block by creating a new Apache virtual host. Replace HOMEBOX_FQDN with the appropriate domain and include this file from the Apache configuration

    /etc/apache2/homebox.apache2.conf#
    ###########
    # Homebox #
    ###########
    <IfModule mod_ssl.c>
    <VirtualHost *:80>
        ServerName ${HOMEBOX_FQDN}
    
        # Force https.
        UseCanonicalName on
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =${HOMEBOX_FQDN}
    
        # Ignore rewrite rules for 127.0.0.1
        RewriteCond %{HTTP_HOST} !=127.0.0.1
        RewriteCond %{REMOTE_ADDR} !=127.0.0.1
    
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>
    </IfModule>
    
    <IfModule mod_ssl.c>
    <VirtualHost *:443>
        UseCanonicalName on
    
        Keepalive On
        RewriteEngine on
    
        ServerName ${HOMEBOX_FQDN}
    
        SSLCompression off
        ProxyRequests Off
        ProxyPreserveHost On
    
        RequestHeader set X-Forwarded-Proto "https"
        RequestHeader set X-Forwarded-Port "443"
    
        # Keep Homebox private
        <Proxy *>
            # Localhost.
            Require ip 127.0.0.1
            Require ip 192.168.0.
    
            # Docker containers.
            Require ip 172.16.
        </Proxy>
    
        ProxyPass / http://127.0.0.1:4014/
        ProxyPassReverse / http://127.0.0.1:4014/
    
        # if <HTTP connection> == 'Upgrade' and <HTTP connection name> == 'websocket':
        #     rewite all URLS to 'wss://...` and proxy them
        RewriteCond %{HTTP:Connection} Upgrade [NC]
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteRule /(.*) ws://127.0.0.1:4014/$1 [P,L]
    
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/${HOMEBOX_FQDN}/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/${HOMEBOX_FQDN}/privkey.pem
    </VirtualHost>
    </IfModule>
    
  8. restart Apache

    systemctl restart apache
    

Footnotes