0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ghostを複数人で投稿出来るようにする

Last updated at Posted at 2025-01-30

サマリ

Ghostは管理人しかコンテンツを投稿出来ないので
複数人投稿するには投稿可能なユーザをInviteする必要があるが
デフォルトのメール設定ではInviteが出来ない
公式で説明されているmailgunは有料なので無料で出来る方法を記載する

環境

  • fedora 40
  • ghost:5-alpine
  • mysql:8.0
  • postfix 3.8.5
  • dovecot 2.3.21.1

前提条件

Production modeでデフォルト動作は出来ている前提

なお、公式

docker-compose.yml
version: '3.1'

services:

  ghost:
    image: ghost:5-alpine
    restart: always
    ports:
      - 8080:2368
    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: example
      database__connection__database: ghost
      # this url value is just an example, and is likely wrong for your environment!
      url: http://localhost:8080
      # contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)
      #NODE_ENV: development
    volumes:
      - ghost:/var/lib/ghost/content

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
    volumes:
      - db:/var/lib/mysql

volumes:
  ghost:
  db:

を取ってきて sudo docker-compose up するだけ

変更内容

postfix

yumでインストール

/etc/postfix/main.cf

/etc/postfix/main.cf
compatibility_level = 3.8
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = localhost
mydomain = localhost
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
 
  
debug_peer_level = 2
debugger_command =
	 PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
	 ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix/samples
readme_directory = /usr/share/doc/postfix/README_FILES
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_security_level = may
meta_directory = /etc/postfix
shlib_directory = /usr/lib64/postfix
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

変更点は以下

  • myhostname
  • mydomain
  • myorigin
  • inet_interfaces
  • inet_protocols
  • relayhost
  • smtpd_sasl_type
  • smtpd_sasl_path
  • smtpd_sasl_auth_enable
  • smtpd_recipient_restrictions

/etc/postfix/master.cf

以下を追加

submission inet n - n - - smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=may
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject

dovecot

yum でインストール

/etc/dovecot/conf.d/10-auth.conf

以下に変更

disable_plaintext_auth = no
auth_mechanisms = plain login

/etc/dovecot/conf.d/10-master.conf

service auth部分を以下に変更
(/var/spool/postfix/private/authの変更を忘れないように)

service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
}

Ghost

起動中のdockerに入る

sudo docker exec -it $(sudo docker ps | grep ghost:5-alpine | awk '{print $1}') /bin/bash

config.production.json

mail部分を以下に変更

"mail":{
   "transport":"SMTP",
   "options":{
      "host":"172.17.0.1",
      "auth":{
         "user":"xxxxxx",
         "pass":"xxxxxx"
      },
      "tls":{
         "rejectUnauthorized":false
      }
   },
   "from":"yano@localhost"
},

ユーザとpassはLinuxユーザのユーザ名とパスワード
fromはそれっぽいのであればOK
ipはGhostがdockerで、postfixがホスト上で動作している前提となっている
rejectUnauthorizedはメールサーバに自己署名で無い証明書が設定されているなら不要

サービスの再起動

sudo systemctl restart postfix dovecot
# sudo systemctl enable postfix dovecot 必要に応じて
sudo docker-compose stop
sudo docker-compose up

Invite

後は管理画面(/ghost/)から歯車マークを選択して設定画面に移動し
StaffのInviteでEditorなどを選択する

つまり管理者からInviteする形になり
管理者は最初に/ghost/でアカウント作成した人になる

Inviteされた人はリンクが送られてくるので
それをクリックすると管理者が/ghost/でアカウント作成するのと同じ画面になる
そこでアカウントを作成するとPost出来るようになる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?