Self hosting Snipe IT ITAM tool
Guide to self hosting Snipe-IT asset management tool using Caddy for reverse proxy
Introduction
Snipe-IT is an open source IT Asset Management software (ITAM). It can be self hosted or hosted on their cloud platform.
ITAM is important because it helps organizations track and manage their technology resources efficiently, ensuring proper utilization. It can help maintaining up-to-date inventory of hardware and software assets, businesses can avoid unnecessary purchases, ensure compliance with licenses, and improve security by identifying vulnerabilities or outdated systems.
In this tutorial I will guide you through the steps to install and configure Snipe-IT on Debian 12, setup Snipe-IT and use Caddy to automatically reverse proxy and generate an SSL certificate.
Steps
Step 1: Pre-requisites
You need docker installed on the vps as we will use the docker to install Snipe-IT. You can follow the instuctions on the docker’s official website.
You also need caddy installed in your system and can follow the instructions on Caddy’s website.
Check and update all other applications using the following.
sudo apt updatesudo apt upgradeStep 2: Installing Snipe-IT
Now we have Docker and Caddy installed on our system we use the following command to to create a directory to install Snipe-IT in.
Create a directory to install the app in and navigate into it.
mkdir snipeitcd snipeitDownload the docker-compose.yml file and .env files.
curl https://raw.githubusercontent.com/snipe/snipe-it/master/docker-compose.yml --output docker-compose.ymlfollowed by
curl https://raw.githubusercontent.com/snipe/snipe-it/master/.env.docker --output .envUse the following command to generate an APP_KEY for the .env file.
docker compose run --rm app php artisan key:generate --showThis is the .env file you need to edit.
You need to edit the following
- The default port is 8000, if you have the port in use then you need to specify another port.
- Enter your generated
APP_KEY - Enter your custom domain
Docker will default to latest if you leave APP_VERSION empty! You can select the version you want from Snipe-it on docker hub
# --------------------------------------------# REQUIRED: DOCKER SPECIFIC SETTINGS# --------------------------------------------APP_VERSION= (Leave empty for latest, or enter version)APP_PORT=8000
# --------------------------------------------# REQUIRED: BASIC APP SETTINGS# --------------------------------------------APP_ENV=productionAPP_DEBUG=false# Please regenerate the APP_KEY value by calling `docker compose run --rm app php artisan key:generate --show`. Copy paste the value hereAPP_KEY=enter app key hereAPP_URL=https://snipeit.domain.com (Enter your custom domain here)# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - TZ identifierAPP_TIMEZONE='UTC'APP_LOCALE=en-USMAX_RESULTS=500
# --------------------------------------------# REQUIRED: UPLOADED FILE STORAGE SETTINGS# --------------------------------------------PRIVATE_FILESYSTEM_DISK=localPUBLIC_FILESYSTEM_DISK=local_public
# --------------------------------------------# REQUIRED: DATABASE SETTINGS# --------------------------------------------DB_CONNECTION=mysqlDB_HOST=dbDB_SOCKET=nullDB_PORT='3306'DB_DATABASE=snipeitDB_USERNAME=snipeitDB_PASSWORD=changeme1234MYSQL_ROOT_PASSWORD=changeme1234DB_PREFIX=nullDB_DUMP_PATH='/usr/bin'DB_DUMP_SKIP_SSL=trueDB_CHARSET=utf8mb4DB_COLLATION=utf8mb4_unicode_ci
# --------------------------------------------# OPTIONAL: SSL DATABASE SETTINGS# --------------------------------------------DB_SSL=falseDB_SSL_IS_PAAS=falseDB_SSL_KEY_PATH=nullDB_SSL_CERT_PATH=nullDB_SSL_CA_PATH=nullDB_SSL_CIPHER=nullDB_SSL_VERIFY_SERVER=null
# --------------------------------------------# REQUIRED: OUTGOING MAIL SERVER SETTINGS# --------------------------------------------MAIL_MAILER=smtpMAIL_HOST=mailhogMAIL_PORT=1025MAIL_USERNAME=nullMAIL_PASSWORD=nullMAIL_TLS_VERIFY_PEER=trueMAIL_FROM_ADDR=you@example.comMAIL_FROM_NAME='Snipe-IT'MAIL_REPLYTO_ADDR=you@example.comMAIL_REPLYTO_NAME='Snipe-IT'MAIL_AUTO_EMBED_METHOD='attachment'
# --------------------------------------------# REQUIRED: DATA PROTECTION# --------------------------------------------ALLOW_BACKUP_DELETE=falseALLOW_DATA_PURGE=false
# --------------------------------------------# REQUIRED: IMAGE LIBRARY# This should be gd or imagick# --------------------------------------------IMAGE_LIB=gd
# --------------------------------------------# OPTIONAL: BACKUP SETTINGS# --------------------------------------------MAIL_BACKUP_NOTIFICATION_DRIVER=nullMAIL_BACKUP_NOTIFICATION_ADDRESS=nullBACKUP_ENV=true
# --------------------------------------------# OPTIONAL: CHANGE PHP UPLOAD LIMITS (UNCOMMENT WHEN NEEDING TO BE CHANGED)# --------------------------------------------#PHP_UPLOAD_LIMIT=10#PHP_POST_MAX_SIZE=10#PHP_UPLOAD_MAX_FILESIZE=10#PHP_MEMORY_LIMIT=10
# --------------------------------------------# OPTIONAL: SESSION SETTINGS# --------------------------------------------SESSION_LIFETIME=12000EXPIRE_ON_CLOSE=falseENCRYPT=falseCOOKIE_NAME=snipeit_sessionCOOKIE_DOMAIN=nullSECURE_COOKIES=falseAPI_TOKEN_EXPIRATION_YEARS=40
# --------------------------------------------# OPTIONAL: SECURITY HEADER SETTINGS# --------------------------------------------APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1,172.16.0.0/12ALLOW_IFRAMING=falseREFERRER_POLICY=same-originENABLE_CSP=falseCORS_ALLOWED_ORIGINS=nullENABLE_HSTS=false
# --------------------------------------------# OPTIONAL: CACHE SETTINGS# --------------------------------------------CACHE_DRIVER=fileSESSION_DRIVER=fileQUEUE_DRIVER=syncCACHE_PREFIX=snipeit
# --------------------------------------------# OPTIONAL: REDIS SETTINGS# --------------------------------------------REDIS_HOST=nullREDIS_PASSWORD=nullREDIS_PORT=6379
# --------------------------------------------# OPTIONAL: MEMCACHED SETTINGS# --------------------------------------------MEMCACHED_HOST=nullMEMCACHED_PORT=null
# --------------------------------------------# OPTIONAL: PUBLIC S3 Settings# --------------------------------------------PUBLIC_AWS_SECRET_ACCESS_KEY=nullPUBLIC_AWS_ACCESS_KEY_ID=nullPUBLIC_AWS_DEFAULT_REGION=nullPUBLIC_AWS_BUCKET=nullPUBLIC_AWS_URL=nullPUBLIC_AWS_BUCKET_ROOT=null
# --------------------------------------------# OPTIONAL: PRIVATE S3 Settings# --------------------------------------------PRIVATE_AWS_ACCESS_KEY_ID=nullPRIVATE_AWS_SECRET_ACCESS_KEY=nullPRIVATE_AWS_DEFAULT_REGION=nullPRIVATE_AWS_BUCKET=nullPRIVATE_AWS_URL=nullPRIVATE_AWS_BUCKET_ROOT=null
# --------------------------------------------# OPTIONAL: AWS Settings# --------------------------------------------AWS_ACCESS_KEY_ID=nullAWS_SECRET_ACCESS_KEY=nullAWS_DEFAULT_REGION=null
# --------------------------------------------# OPTIONAL: LOGIN THROTTLING# --------------------------------------------LOGIN_MAX_ATTEMPTS=5LOGIN_LOCKOUT_DURATION=60RESET_PASSWORD_LINK_EXPIRES=900INVITE_PASSWORD_LINK_EXPIRES=1500
# --------------------------------------------# OPTIONAL: MISC# --------------------------------------------LOG_CHANNEL=stderrLOG_MAX_DAYS=10APP_LOCKED=falseAPP_CIPHER=AES-256-CBCAPP_FORCE_TLS=falseGOOGLE_MAPS_API=LDAP_MEM_LIM=500MLDAP_TIME_LIM=600Step 3: Configuring Caddy
After setting up Snipe-IT, we must configure Caddy.
Use the following command to open the CaddyFile
sudo nano /etc/caddy/CaddyfileClear out the default contents and paste the following in the file. Replace snipeit.domain.com with your actual domain.
snipeit.domain.com { reverse_proxy localhost:8000}Save and restart Caddy service using the following command.
sudo systemctl restart caddyStep 4: Start Snipe-IT
After configuring Caddy, move into your snipeit directory. Start the application using the following command.
docker compose up -dYou can access your application on the URL mentioned in the CaddyFile and begin setting up your instance.
Update
Since we are using the latest tag by default due to leaving APP_VERSION empty, we simply need to restart docker using the following to update.
docker compose downand
docker compose up -dIf you are using a specific version, you would need to write the newer version tag in the APP_VERSION and restart docker using the above commands to update.
Conclusion
With this, your SnipeIT instance is now fully deployed and secured behind a reverse proxy, you have control over your IT assets.
If you run any issues or need further help, fell free to reach out via email or open a discussion