redmine LDAPでエラー「Internal error An error occurred on the page you were trying to access.」が発生した場合の対処法

redmine LDAPでエラー「Internal error An error occurred on the page you were trying to access.」が発生した場合の対処法

redmineで、LDAP通信時にエラー「Internal error An error occurred on the page you were trying to access. If you continue to experience problems please contact your Redmine administrator for assistance.」が発生した場合の対処法を記述してます。

環境

  • OS CentOS Stream release 9
  • docker 20.10.21
  • docker-compose v2.10.0
  • redmine 5.0.3

エラー全文

ユーザーを「LDAP認証」で作成時に発生。作成ボタン押下時に発生しました。
※「docker-compose.yml」から構築してます。

エラー

Internal error
An error occurred on the page you were trying to access.
If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error.

Back

画像

原因

logをみてみるとmysqlの文字コードの問題

> docker logs -f redmineのイメージ

FATAL -- :   
ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: '\xE5\x8B\x9D\xE5\xA4\xAB' for column 'firstname' at row 1):

対処法

「docker-compose.yml」に文字コードの指定を追加して、再度、構築したら直りました。

version: '3.1'

services:

  redmine:
    image: redmine:latest
    restart: always
    ports:
      - 8080:3000
    environment:
      REDMINE_DB_MYSQL: db
      REDMINE_DB_PASSWORD: example
      REDMINE_SECRET_KEY_BASE: supersecretkey
    volumes:
      - redmine-files:/usr/src/redmine/files
  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: redmine
    volumes:
    - redmine-db:/var/lib/mysql
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
  
volumes:
  redmine-db:
  redmine-files: