Blog

Blog

TODO: Using foobar2000 to verify music file integrity

Using foobar2000 to verify music file integrity

Couldn't found install component feature in MacOS version.

Download File Integrity Verifier

Download component from following location

File Integrity Verifier

Install component

Install component using following steps

  • Open the foobar2000 preferences dialog (click "File | Preferences" or use the CTRL+P keyboard shortcut).
  • Select the Components page.
  • Either click the Install... button and locate the component archive, or simply drag it on to the list.
  • Click OK ...
  • Restart.

Testing

Tested on following formats

  • flac

Cons

  • Failed to test on dff format.

TODO

Test

TODO: Cannot set LC_CTYPE/LC_ALL to default locale: No such file or directory

Cannot set LC_CTYPE/LC_ALL to default locale: No such file or directory

Error description

Below error repeatly appears when run apt upgrade.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
Scanning processes...
Scanning candidates...
Scanning linux images...
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory

Check /etc/default/locale file,

#  File generated by update-locale
LANG=en_US.UTF-8

it doesn't contain following lines

LC_CTYPE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

Tried but failed

Tried to run following commands, the errors are still there.

locale-gen "en_US.UTF-8"
dpkg-reconfigure locales

Also added following lines in /etc/environment and /etc/default/locale, still failed

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

Play music with DAC in MacOS

Play music with DAC in MacOS

Use music players in MacOS and output to DAC directly.

Colibri

Website: https://colibri-lossless.com/

Setup

  • Go to Preferences -> Output screen
  • Change Output Device
  • Change DSD mode to DoP if DAC supports DSD.
  • Change PCM mode from to the highest DSD format DAC can play
  • Enable Exclusive / Hog mode if don't expect OS sounds appear
  • Enable Audio Signal Bypass if want to disable OS sound functions
  • Auto-raise system volume to 100% for this device if the DAC has no problem such as reseting voice level. For example, Creative portable DAC can suddent raise to very high level when turning on.
  • Changing device requires Remember... setting to be off

Note: If using Exclusive mode, need to change system default sound device to other device in order to use the device selected for music playing.

Cons

  • Free
  • Can play many format
  • Changing options require player restart
  • Can not specify DAC unsupported formats to be software decoded

VLC

Setup

Forgot how to change them.

  • Go to **Preferences"
  • Click on Show All at bottom left corner
  • ...

Cons

  • Cannot play DFF format
  • Not easy to find out options
  • Mainly for video playing

JRiver Media Center

This is a library style player, but user interface isn't user friendly as iTune, and library isn't manging not well at all.

Pros

  • Not free and yearly upgrade
    • Master (for Windows, Mac, and Linux) License Upgrade $34.98
    • Single OS Upgrade $22.98

Cons

  • Support Windows, Mac, and Linux

Configure trust self generated CA certificate of docker registry

Configure trust self generated CA certificate of docker registry

When self generated CA certificate has not been trusted by docker client, following error occurres

... x509: certificate signed by unknown authority

Install CA certificate for docker only

Docker can install registry CA as /etc/docker/certs.d/<registry[:port]>/ca.crt. For example,

/etc/docker/certs.d/my-registry.example.com:5000/ca.crt

Note: If port is 443, it should be omitted. Otherwise, it won't work.

Install CA certificate into system folder

To install self generated CA certificate for operating system, follow the page below.

Install self generated CA certificate into Linux OS

Restart docker service to take effect

The restart docker service after CA certificate installed.

systemctl restart docker

Backup docker container using shell script

j# Backup docker container using shell script

Backup

Using following shell script to backup docker container with date tag

#!/bin/bash
# backup-docker.sh <container_name> <registry_path>

container=$1            # <container_name>
repo_prefix=$2          # <registry>/<prefix>
registry=${repo_prefix//\/*/}

repo_name=$repo_prefix/`hostname`/$container
repo_path=$repo_name:`date +%Y%m%d`

docker commit $container $repo_path
docker login $registry
docker push $repo_path

Note: If following certification error occurred, follow the page below to install ceritficate.

Configure trust self generated ca certificate of docker registry

List repo

Using following shell command to list repo list in docker registry

curl https://bianxi:$PASSWORD@${registry}/v2/_catalog

Sample output

{"repositories":["bianxi/dnsmasq","bianxi/heart/dnsmasq"]}

List tags

Using follwing shell command to list tags for one repo in docker registry

echo curl https://bianxi:$PASSWORD@${registry}/v2/${repo}/tags/list

Sample output

{"name":"bianxi/heart/dnsmasq","tags":["20210620","20210621","20210622","20210623","20210624","20210625","20210626","20210627"]}

Get digest for tag

Get digest by pull image

docker pull registry.bx.net/bianxi/heart/dnsmasq:20210624

Sample output

20210624: Pulling from bianxi/heart/dnsmasq
...
22b5d63ad977: Already exists
8e2e66517d7e: Pull complete
Digest: sha256:7535af1f65524f9200b901fc31b9c779819e45c0502ef99605666842a319908f

Verify digest

curl https://bianxi:$PASSWORD@registry.bx.net/v2/bianxi/heart/dnsmasq/manifests/sha256:xxxxxxxxxxxxxxxx
curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X GET https://bianxi:$PASSWORD@registry.bx.net/v2/bianxi/heart/dnsmasq/manifests/20210624 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}'

Delete local repo

docker rmi registry.bx.net/bianxi/heart/dnsmasq:<tag>

Delete tag

curl -X DELETE https://bianxi:$PASSWORD@registry.bx.net/v2/bianxi/heart/dnsmasq/manifests/sha256:xxxxxxxxxxxxxxxx

Run garbage-collect

docker exec registry bin/registry garbage-collect --delete-untagged /etc/docker/registry/config.yml

Restart registry if necessary

docker restart registry

Increase client_max_body_size in NGINX for docker registry

Increase client_max_body_size in NGINX for docker registry

Error "413 Request Entity Too Large" occurred when push image to docker registry.

To fix this issue, add client_max_body_size in NGINX configuration file for docker registry as below, then restart NGINX.

server {
    listen 443;
    server_name hub.bx.net docker.bx.net registry.bx.net dockerhub.bx.net;

    location /v2/ {
        proxy_pass https://registry.my_bridge/v2/;
        proxy_set_header  Authorization $http_authorization;
        proxy_pass_header Authorization;
    }

    client_max_body_size 100M;
}

Create your website with blocks

Create your website with blocks

This is an example page from WordPress.

Add block patterns

Block patterns are pre-designed groups of blocks. To add one, select the Add Block button [+] in the toolbar at the top of the editor. Switch to the Patterns tab underneath the search bar, and choose a pattern.

Frame your images

Twenty Twenty-One includes stylish borders for your content. With an Image block selected, open the "Styles" panel within the Editor sidebar. Select the "Frame" block style to activate it.

Overlap columns

Twenty Twenty-One also includes an overlap style for column blocks. With a Columns block selected, open the "Styles" panel within the Editor sidebar. Choose the "Overlap" block style to try it out.

“Roses Trémières” by Berthe Morisot
“In the Bois de Boulogne” by Berthe Morisot
“Young Woman in Mauve” by Berthe Morisot

TODO: Change wordpress TCP port

Change wordpress TCP port

After change port in settings, also redeployed dockers, the website is unreachable.

Change port

Update in setting of wordpress

Update docker-compose.yml file

Destory and recreate dockers

docker-compose down
docker-compose up -d

Note: Failed

Change back port

Change port back using by update option values database.

Access mariadb docker

docker exec -it wp_db_1 bash

Login to mariadb

mysql -u wordpress -p

Search option value

MariaDB [wordpress]> select * from wp_options where option_value like '%192.168.1.14%';
+-----------+-------------+------------------------+----------+
| option_id | option_name | option_value           | autoload |
+-----------+-------------+------------------------+----------+
|         1 | siteurl     | http://192.168.1.14:80 | yes      |
|         2 | home        | http://192.168.1.14:80 | yes      |
+-----------+-------------+------------------------+----------+
2 rows in set (0.058 sec)

Update value back

MariaDB [wordpress]> update wp_options set option_value='http://192.168.1.14:8080' where option_value='http://192.168.1.14:80';
Query OK, 2 rows affected (0.008 sec)
Rows matched: 2  Changed: 2  Warnings: 0

MariaDB [wordpress]> select * from wp_options where option_value like '%192.168.1.14%';
+-----------+-------------+--------------------------+----------+
| option_id | option_name | option_value             | autoload |
+-----------+-------------+--------------------------+----------+
|         1 | siteurl     | http://192.168.1.14:8080 | yes      |
|         2 | home        | http://192.168.1.14:8080 | yes      |
+-----------+-------------+--------------------------+----------+
2 rows in set (0.058 sec)

MariaDB [wordpress]> quit

WordPress URLs point actual server behind NGINX

WordPress URLs point actual server behind NGINX

NGINX did not translate URL correctly

When accessing server via NGINX, it didn't translate URLs in page to the URL accessing.

For example, the URL is https://example.com/sample.html, the server behind is https://192.168.1.11/sample.html, the NGINX is still leaving it without translating.

I have done following, but not useful

  1. Updated both options siteurl and home in database
update wp_options set option_value='http://newhost:8080' where option_name='siteurl';
update wp_options set option_value='http://newhost:8080' where option_name='home';
  1. Added host and port in wp_config.php
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
      $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
      $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
}

Someone suggested following lines as well, but I didn't do it.

define('WP_HOME','https://test.com/blog/');
define('WP_SITEURL','https://test.com/blog/');
  1. Updated NGINX configuration.
proxy_pass http://newhost

Solution

Modify NGINX configuration

Configure https

server {
    server_name  blog.bianxi.com;

    # SSL configuration
    listen 443 ssl;

    ssl_certificate     conf.d/www.bianxi.com.crt;
    ssl_certificate_key conf.d/www.bianxi.com.key;

    location / {
        proxy_pass      'http://192.168.1.14:8080';
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_read_timeout    90;
        proxy_connect_timeout 90;
        proxy_redirect        off;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Port 443;
        proxy_set_header Proxy "";
    }
}

Configure http redirect

server {
    listen       80;
    server_name  blog.bianxi.com;

    return 301 https://$host$request_uri;
}

Config wp-config.php

Add following lines in wp-config.php

//$_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/",  $_SERVER['REQUEST_URI']);

if($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;

    define('WP_HOME','https://blog.bianxi.com/');
    define('WP_SITEURL','https://blog.bianxi.com/');
}

If change URL is required

Change location in NGINX configuration file, and the URL replace were used if requires changing of URL as well in wp-config.php file.

Docker Compose – wordpress

Docker Compose - wordpress

Simple steps to start using docker compose to create wordpress dockers.

Installation

Install docker-compose package

Run following command on ubuntu and armbian servers.

apt install docker-compose

Create dockers

Create folder as project name wp

The project name will be used as a part of docker container name.

mkdir -p /app/wp

Create docker compose file

Using vi to create file docker-compose.yml in directory /app/wp

version: "3.3"

services:
  db:
    image: mariadb:latest
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "3306:3306"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - wordpress_data:/var/www/html
    ports:
      - "80:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
volumes:
  db_data: {}
  wordpress_data: {}

Run docker compose command

docker-compose up -d

Destroy dockers

Run docker compose command

docker-compose down

Destroy dockers and their volumes

docker-compose down --volumes