一個人自娛自樂/需密碼查看post佈署完成

ghost博客自帶得all private或者some posts設為members only,但我想有啲posts用密碼睇(唔想搞訂閲members),所以就自己摷資料整!

1)首先新增一個要密碼嘅post嘅對應tag,呢度設為hash-private(感覺上用internal好過public tag)

2)修改setting中lab嘅rounts文件,新增/private/路徑處理tag咗hash-private嘅post:

routes:

collections:
  /private/:
    permalink: /private/{slug}/
    filter: tag:hash-private
    template: index
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

3)修改nginx配置,新增驗證:

呢邊因為係用docker搭建ghost,所以需要反向代理。同時因為開放private主頁,所以寫多一個唔使驗證嘅"="精確匹配

location ^~ /private/ {
      
      auth_basic "Authorization";
      auth_basic_user_file ***;
      proxy_pass ***;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Real-Port $remote_port;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header REMOTE-HOST $remote_addr;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
}

location = /private/ {
      
      proxy_pass ***;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Real-Port $remote_port;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header REMOTE-HOST $remote_addr;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
}

最後效果可以睇一個人自娛自樂專欄

評論留言区