banner
acai

acai

对世界与新技术充满好奇
github
email
bilibili
zhihu

Set up Umami using Docker without docker-compose

Assuming the server has docker and nginx installed, and the server IP is accessible from the public network.

Pulling Images#

  1. Pull the database image

    docker pull postgres:15-alpine
    
  2. Pull the umami image

    docker pull docker.umami.is/umami-software/umami:postgresql-latest
    

Starting the Database Service#

  1. Create a local path to persistently save database data

    mkdir postgresql-data
    
  2. Create a docker network for the umami container to access

    docker network create umami_sql_network
    
  3. Start the database service, replacing /root/umami/postgresql-data with the full path created in the first step

    docker run -d --name umami_database --network umami_sql_network --network-alias umami_database -e POSTGRES_DB=umami -e POSTGRES_USER=umami -e POSTGRES_PASSWORD=umami -v /root/umami/postgresql-data:/var/lib/postgresql/data postgres:15-alpine
    
  4. Check the database container logs and status

    • Check the database container logs: docker logs umami_database
    • Check running docker containers: docker ps

Starting the umami Container#

  • Replace APP_SECRET with a random string. If you do not need nginx reverse proxy, change -p 127.0.0.1:3000:3000 to -p 3000:3000 to access directly at http://your_ip:3000

    docker run -d --name umami --network umami_sql_network -e DATABASE_URL=postgresql://umami:umami@umami_database:5432/umami -e DATABASE_TYPE=postgresql -e APP_SECRET=ewgyifufsrgyuyhuserfyger -p 127.0.0.1:3000:3000 docker.umami.is/umami-software/umami:postgresql-latest
    
  • Check the umami container logs: docker logs umami

  • Check running docker containers: docker ps

nginx Reverse Proxy (Optional)#

Use nginx to proxy the umami service and configure the https certificate.

Create a new configuration file /etc/nginx/conf.d/umami.conf

vim /etc/nginx/conf.d/umami.conf

Fill in the following configuration, with server_name and https certificate paths (ssl_certificate, ssl_certificate_key) for reference, and configure according to your domain and certificate paths.

server {
    listen 443 ssl;
    http2 on;
    server_name umami.hyacm.com;

    ssl_certificate /root/lobe-chat-db/hyacm.com.cert;
    ssl_certificate_key /root/lobe-chat-db/hyacm.com.key;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://127.0.0.1:3000;
        # proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size 20000M;
    }
}

Reload the nginx service

systemctl reload nginx.service

Or restart the nginx service

systemctl restart nginx.service
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.