LoginSignup
17
25

More than 5 years have passed since last update.

PostgreSQLで外部許可

Posted at

DBを入れると必ず行う許可的な設定を毎回調べるのは面倒なので、ざっくりとまとめてみました。

postgres.conf
listen_addresses = "[IPアドレス]"

Ex.全外部アクセスを許可する(あんまりやることはないけど)

listen_addresses = '*'

pg_hba.conf

host  DB名  ユーザ名  接続を許可するIPアドレス    trust

Ex1. 全IPからのアクセスを許可する(パスワードなし)

host  all  all  0.0.0.0/0    trust

Ex2. Alexというユーザ名でPostgresデータベースに対してローカルIPからのアクセスを許可する(パスワード認証)

host  Postgres  Alex   192.168.0.0/16    password

もっと細かい話は以下のURLを参考にしてください。
要望があればExあたりに追加しようかな。

参考文献:
https://ameblo.jp/jyokke/entry-10586621928.html
https://www.postgresql.jp/document/8.4/html/auth-pg-hba-conf.html
http://hacknote.jp/archives/6016/

17
25
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
17
25