你必須懂的postfix+amavisd擋廣告順序

就連我都會誤解!
以為只要在postfix的main.cf裡面設定各式各樣的擋廣告方式(包含參考黑名單網站),就可以高枕無憂了,
可是事情並不是我們憨人想得這麼簡單
擋廣告總有順序的.

  1. amavisd 優先
    這部分很重要,有時候很多廣告商,都利用gmail , amazons發送廣告信, amavisd 很容易直接pass, 要解決這問題, 就只能土法煉鋼, 將廣告的網域,email寫到amavisd的黑名單上.
  2. postfix 次要
    若amavisd認定pass , 這邊再怎麼設定都沒用, 因為根本不會跑到這裡來.
    若amavisd沒有認定pass, 也沒認定是廣告(分數不足), 就會跑到這裡來,

我的設定, 就是讓amavisd可以定義黑白名單, 接下來才是設定postfix本身的名單限制
推薦看一下我製作的docker mail server設定
https://github.com/WilliamFromTW/docker-Postfix-AD

啟用postgrey心得

因為postgrey的機制會造成收信延遲, 所以必須設定白名單,與自動白名單,讓常用的郵件不再受限制.
1.白名單可在/etc/postfix/postgrey_whitelist_clients.local 新增
2.自動白名單,以centos 7為例子, 可在 /etc/sysconfig/postgrey 新增, 意指35天內,只要成功三次,就會一直是白名單成員
POSTGREY_OPTS=”–delay=60 –auto-whitelist-clients=5 –max-age=35″

cetnos 7 + postfix 新增dkim功能

  1. 安裝

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y opendkim

  1. 產生private key與dns的TXT Record

opendkim-genkey -d <domain name>
cp default.* /etc/opendkim/keys
chown -R opendkim:opendkim /etc/opendkim

  1. 修改/etc/opendkim.conf
    確認該設定檔案有以下的設定( KeyFile /etc/opendkim/keys/default.private 要mark起來 )

Mode sv
Socket inet:8891@127.0.0.1
Canonicalization relaxed/simple
Domain <domain name>
#KeyFile /etc/opendkim/keys/default.private
KeyTable refile:/etc/opendkim/KeyTable
#ps 若使用測試軟體出現invalid data set, 請改成 KeyTable /etc/opendkim/KeyTable
SigningTable refile:/etc/opendkim/SigningTable
ExternalIgnoreList refile:/etc/opendkim/TrustedHosts
InternalHosts refile:/etc/opendkim/TrustedHosts

  1. 修改 /etc/opendkim/KeyTable

default._domainkey.<domain name> <domain name>:default:/etc/opendkim/keys/default.private

以 test.com 為例子

default._domainkey.test.com test.com:default:/etc/opendkim/keys/default.private

  1. 修改 /etc/opendkim/SigningTable

*@<domain name> default._domainkey.<domain name>

以test.com為例子

*@test.com default._domainkey.test.com

  1. 修改 /etc/opendkim/TrustedHosts

127.0.0.1
<mail host name>
<domain name>

以 test.com 為例子

127.0.0.1
mail.test.com
test.com

  1. 新增以下設定 /etc/postfix/main.cf

smtpd_milters = inet:127.0.0.1:8891
non_smtpd_milters = $smtpd_milters
milter_default_action = accept

  1. 將/etc/opendkim/key/default.txt的資料更新到dns上

  2. 啟用service

systemctl start opendkim ; systemctl enable opendkim ; systemctl restart postfix

  1. 測試
    • opendkim-testkey -x /etc/opendkim.conf 若無錯誤訊息代表成功
    • 測試網站 https://www.appmaildev.com/

v2ray初體驗-使用v2-ui初階安裝

安裝v2ray之前,你必須符合以下基本技術基礎

  1. 會安裝CEntOS 7
  2. 懂apache httpd 2.4基本設定
  3. 懂dns, 懂申請let’s Encrypt

你也必須準備以下軟硬體

  1. 安裝好CEntOS7
  2. 有Internet IP
  3. 有網域,並可賦予該系統一個網路名稱

開始安裝

1. 安裝v2ray
到這個神人網站 https://github.com/sprov065/v2-ui/
一鍵安裝
bash <(curl -Ls https://blog.sprov.xyz/v2-ui.sh)

2. 安裝完畢網站預設是 http://ip:65432 預設帳號密碼都是admin , 記得登入修改密碼


3. 以下示範兩種連線, 一種http/2(h2), 另一種透過apache httpd(port 443)代理連到後端websocket
3.1 設定 h2 連線
Server:


client:
v2ray初體驗-使用v2-ui初階安裝



3.2
Server 設定:


Clinet 設定:
websocket , port 用443, 要輸入tls

apache httpd 設定:

ServerName xxx
ErrorLog /var/log/httpd/ssl_error_log1
TransferLog /var/log/httpd/ssl_access_log1

SSLEngine On
SSLProxyEngine On
SSLCertificateFile /etc/letsencrypt/live/xxx/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxx/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/xxx/fullchain.pem
## v2-ui management
RewriteEngine On
ProxyPass / http://localhost:65432/
ProxyPassReverse / http://localhost:65432/
## server
RewriteRule /ray/(.*) ws://localhost:1234/$1 [P,L]
RewriteCond %{HTTP:Upgrade} =websocket [NC]
ProxyPass /ray/ http://localhost:1234/
ProxyPassReverse /ray/ http://localhost:1234/


4. 心得
若是使用3.1 , 使用httpd/2的方式
若是使用3.2可以看起來像是https的存取

5. 額外指令

 v2-ui              - 显示管理菜单 (功能更多)
 v2-ui start        - 启动 v2-ui 面板
 v2-ui stop         - 停止 v2-ui 面板
 v2-ui restart      - 重启 v2-ui 面板
 v2-ui status       - 查看 v2-ui 状态
 v2-ui enable       - 设置 v2-ui 开机自启
 v2-ui disable      - 取消 v2-ui 开机自启
 v2-ui log          - 查看 v2-ui 日志
 v2-ui update       - 更新 v2-ui 面板
 v2-ui install      - 安装 v2-ui 面板
 v2-ui uninstall    - 卸载 v2-ui 面板

httpd reverse proxy 需要注意的設定

一般來說有些需要保護的web service,可以躲到httpd proxy背後, 好處如下:

  1. 比較安全, 尤其是老舊的web service,
  2. 統一由httpd proxy 保管SSL證書很方便

這些在背後的service 通常只要讓httpd proxy 知道該service本地端的ip&port 就能存取, 並且晉升https的行列,非常方便.
基本上調整如下:

 <VirtualHost *:443>
 ServerName  xxx.yyy.com
 ErrorLog /var/log/httpd/ssl_error_log1
 TransferLog /var/log/httpd/ssl_access_log1
 
 SSLEngine On
 SSLProxyEngine On
 SSLCertificateFile /etc/letsencrypt/live/xxx.yyy.com/cert.pem
 SSLCertificateKeyFile /etc/letsencrypt/live/xxx.yyy.com/privkey.pem
 SSLCACertificateFile /etc/letsencrypt/live/xxx.yyy.com/fullchain.pem
 

 ProxyPass / http://zzz.yyy.com.tw:80/
 ProxyPassReverse / http://zzz.yyy.com:80/
 </VirtualHost> 

以上設定若是遇到網址是%2F, 通常都會出問題,
這是slash html encode的問題, apache預設不支援該編碼, 因此可以加上 AllowEncodeSlashesnocanon

<VirtualHost *:443>
AllowEncodedSlashes on
ProxyPass / http://zzz.yyy.com.tw:80/ nocanon
ProxyPassReverse / http://zzz.yyy.com:80/ nocanon
</VirtualHost>

1 ... 7 8 9 10 11 ... 14