2017年9月20日 星期三

OFFICE 表格內的文字消失

微軟9月份的Office軟體更新後會造成表格合併儲存格的文字消失,還沒更新的就先不要更新。

已經安裝的也有解決辦法,將已更新的 KB3213656 或 KB4011039 修正檔移除就可恢復正常了。

2017年8月19日 星期六

OFFICE 365 搭配 Linux BIND DNS 設定

OFFICE 365 DNS網域設定方式(For Linux)

在Zone設定檔裡增加O365 網域 DNS記錄
新增下列DNS記錄:

;o365 SubDomain
$ORIGIN o365.example.com.tw.

;O365用來驗證網域是否歸您所有
o365.example.com.tw. 3600 IN TXT "MS=ms12345678"

增加上面兩列設定就可完成OFFICE 365的網域驗證。

; 將網域的內送郵件傳送到 Office 365 中的 Exchange Online 服務
o365.example.com.tw. 3600 IN MX 5 o365-example-com-tw.mail.protection.outlook.com.

; 防止他人使用您的網域來傳送垃圾郵件或其他惡意電子郵件
o365.example.com.tw. 3600 IN TXT "v=spf1 include:spf.protection.outlook.com -all"

;O365各項服務主機的DNS記錄
;自動導引outlook用戶端與Exchange Online連結
autodiscover.o365.example.com.tw. 3600 IN CNAME autodiscover.outlook.com.

; Lync用戶端會使用它來協助尋找 Lync Online 服務並登入
sip.o365.example.com.tw. 3600 IN CNAME sipdir.online.lync.com.

; Lync 行動用戶端會使用它來協助尋找 Lync Online 服務並登入
lyncdiscover.o365.example.com.tw. 3600 IN CNAME webdir.online.lync.com.

; Office 365 會使用它來將驗證導向正確的身份識別平台
msoid.o365.example.com.tw. 3600 IN CNAME clientconfig.microsoftonline-p.net.

; Office 365 行動裝置管理 (MDM)
enterpriseregistration.o365.example.com.tw. 3600 IN CNAME enterpriseregistration.windows.net.

; Office 365 行動裝置管理 (MDM)
enterpriseenrollment.o365.example.com.tw. 3600 IN CNAME enterpriseenrollment.manage.microsoft.com.

;協調 Lync 用戶端之間的資訊流程
_sip._tls.o365.example.com.tw. 3600 IN SRV 100 1 443 sipdir.online.lync.com.

;藉由啟用 SIP 同盟,讓 Office 365 網域與 Skype 之外的用戶端共用
_sipfederationtls._tcp.o365.example.com.tw. 3600 IN SRV 100 1 5061 sipfed.online.lync.com.

如郵件寄送是使用主網域(example.com.tw)來寄送信件,也需在主網域(example.com.tw)設定上列設定值(注意:網域名需修改為主網域,例: o365.example.com.tw --> example.com.tw)。



2017年7月21日 星期五

iRedMail Server 主機、DB 備份還原


因為發生慘案,先趕快將 iRedMail Server 還原後回想的還原步驟,可能會漏掉還原過程中少數步驟。但有大部份的還原步驟總比沒有好,有機會..................吔!!!!!
希望不會再有機會用到。


安裝時,有可能系統採最小安裝,會缺少某些 compile 工具程式,依提示補上即可。

一、安裝 CentOS 或 Ubuntu、iRedMail
1.安裝 CentOS 或 Ubuntu


2.下載 iRedMail:
請選擇最新版本下載:
https://bitbucket.org/zhb/iredmail/downloads/
tar -xvf iRedMail-x.x.x.tar.bz2
cd iRedMail-x.x.x
bash iRedMail.sh


3.iRedMail 固定的設定畫面,依它的設定步驟提供各項資料設定。
設定過程中要先建立一個 domain(如有多個 Domain 挑一個預設的 Domain)、MySQL 密碼、管理者帳號密碼(帳號預設為:postmaster@domain_name)。


4.安裝 Let’s Encrypt(這篇是講還原,所以沒有安裝後續修改 Apache、nginx 的設定方式)
yum install -y git bc wget


git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt


/opt/letsencrypt/letsencrypt-auto certonly --standalone --email xxx@example.com --agree-tos -d example.com (可利用 -d 加多個Domain)


自動更新 SSL 憑證設定檔:
cp /opt/letsencrypt/examples/cli.ini /usr/local/etc/le-renew-webroot.ini


編輯自訂設定檔(沒備份到):
vi /usr/local/etc/le-renew-webroot.ini
修改(必須和原來申請SSL KEY填的資料一樣,不然就利用上面的步驟重新申請 SSL):
rsa-key-size = 4096
email = xxxxx@example.com
domains = example1.com, example2.com …………..
webroot-path = /opt/www/    #roundcubemail 安裝目錄


下載 SSL 更新程式:
yum install curl
curl -L -o /usr/local/sbin/le-renew-webroot https://gist.githubusercontent.com/thisismitch/e1b603165523df66d5cc/raw/fbffbf358e96110d5566f13677d9bd5f4f65794c/le-renew-webroot


手動執行,測試 shell script 更新憑證 :
/usr/local/sbin/le-renew-webroot


加入 Crontab 排程執行憑證更新 :
crontab -e
設定每個禮拜一的凌晨 2:30 (排程自訂)進行一次憑證的檢查及更新
30 2 * * Mon /usr/local/sbin/le-renew-webroot >> /var/log/le-renewal.log;systemctl restart nginx.service postfix.service dovecot.service
這樣就有了一個半永久的 SSL 憑證


二、還原設定
1.從備份的 etc 資料夾複製  letsencrypt 資料夾到 /etc 下


2.還原 postfix 設定檔:
main.cf(確認 main.cf 裡是否有另外套件的設定資料檔案,如有一併還原)
master.cf


3.還原 dovecot.conf 設定檔(LOG 檔 owner 為:vmail:vmail)


4.還原 nginx.conf、conf.d/default.conf
PS:
連線時出現: 502 bad gateway 有可能是 nginx.conf 裡的
server unix:/var/run/php-fpm.socket 路徑指向錯誤


5.產生新的 DKIM KEY(檔案路徑在 /var/lib/dkim,沒備份到)
amavisd -c /etc/amavisd/amavisd.conf genrsa /var/lib/dkim/example.com.pem 2048
chown amavis:amavis /var/lib/dkim/example.com.pem
chmod 400 /var/lib/dkim/example.com.pem
systemctl restart amavisd


檢查:
amavisd -c /etc/amavisd/amavisd.conf showkeys
amavisd -u amavis -c /etc/amavisd/amavisd.conf debug


記得修改 DNS DKIM 設定。


6.修改 amavisd.conf,增加 Domain (公司有多個網域都要加入,另不要用舊的設定檔,除非版本相同)


7.還原備份的 vmail1 裡的使用者信箱(直接搬移 各個 Domain 資料夾進 /var/vmail/vmail1/)


8.還原 MySQL DB
先解壓縮 iRedMail 備份的 DB:
zip2 -d xxxxxxx

還原 DB:
mysql -uroot -p amavisd < amavisd-2017-07-20-03\:30\:08.sql
mysql -uroot -p iredadmin < iredadmin-2017-07-20-03\:30\:08.sql
mysql -uroot -p iredapd < iredapd-2017-07-20-03\:30\:08.sql
mysql -uroot -p roundcubemail < roundcubemail-2017-07-20-03\:30\:08.sql
mysql -uroot -p vmail < vmail-2017-07-20-03\:30\:08.sql
還回以上的 DB 即可,切勿還原 sql DB

9.觀察 LOG 看是否有錯誤訊息



2017年6月30日 星期五

ownCloud 掛載 Google Drive、DropBox

Google 端設定:
1.要申請 Google API 認證 key 前,Chrome 先登入要申請的 Gmail 帳號

2.申請 Google API key 網址


3.這裡是申請 ownCloud 讀取 Google Drive 的認證 key

選擇啟用 Google Drive API

出現要建立專案的提示

建立專案

專案成功建立後,再選擇啟用 Google Drive API

建立 憑證




要不要下載 JSON 認證檔案都沒關係,可從網頁內查詢得到

完成的畫面

ownCloud 端設定:

出現錯誤訊息頁面:
表示要先加入 Google 的  Allow Risky Access Permissions By Unreviewed Apps 群組

加入群組後,再回到 ownCloud 按<允許存取>重新連結 Google Drive 一次。
重新連結就會出現:

ownCloud 成功加上 Google Drive 後,就可以退出 Allow Risky Access Permissions By Unreviewed Apps 群組了。

DropBox APPS 認證 KEY 網頁:

DropBox 的作法更簡單,目前 ownCloud v10 只支援 OAuth1 認證。

按 Create app 後,就產生一組認證 KEY & 金鑰


DropBox 二個步驟搞定,再到 ownCloud 儲存區掛載 DropBox 空間。

新增 DropBox 儲存區,輸入 APP key 及 金鑰後,按<允許存取>






2017年6月29日 星期四

ownCloud 安裝 OnlyOffice Plug-in


ownCloud 安裝 OnlyOffice Plug-in:
# cd /var/www/owncloud/apps/
# git clone https://github.com/ONLYOFFICE/onlyoffice-owncloud.git onlyoffice
# chown -R www-data:www-data onlyoffice



切換到 owncloud web 設定:

設定 ownCloud OnlyOffice Plug-in 連結 OnlyOffice Document Server:






2017年6月23日 星期五

Ubuntu 16.04 安裝 OnlyOffice Document Server 整合 ownCloud 雲端硬碟

官網安裝步驟介紹:

在 CentOS 及 Ubuntu 安裝試過,結果 CentOS 怎麼設定都無法正常整合 OnlyOffice。
改用 Ubuntu 裝好後不用調整設定,直接可用。

更新 Ubuntu
# apt-get update && apt-get upgrade && apt-get dist-upgrade
# apt-get install -y curl

新增套件庫來源
# echo "deb http://archive.ubuntu.com/ubuntu xenial main universe multiverse" | tee -a /etc/apt/sources.list

安裝 nodejs 套件
# curl -sL https://deb.nodesource.com/setup_6.x | bash -
# apt-get install -y nodejs

安裝 PostgreSQL
# apt-get install -y postgresql

PostgreSQL 建立 onlyoffice 資料庫及帳號
# sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
# sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
# sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

安裝 redis
# apt-get install -y redis-server

安裝 RabbitMQ
# apt-get install -y rabbitmq-server

安裝 Document Server
新增 GPG key
# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5

新增 Document Server 套件庫
# echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | tee /etc/apt/sources.list.d/onlyoffice.list
# apt-get update
# apt-get install -y onlyoffice-documentserver

新增字型(可不新增字型):
# mkdir /usr/share/fonts/chinese
# cd /usr/share/fonts/chinese
# 上傳字型
# mkfontscale
# mkfontdir
# apt-get install fontconfig
# fc-cache -fv
# documentserver-generate-allfonts.sh

Ubuntu 16.04 安裝 中文字型:
# apt-get install -y cabextract fonts-linuxlibertine ttf-mscorefonts-installer

字型英文名稱:
微軟正黑體:Microsoft JhengHei
標楷體:DFKai-SB
細明體:MingLiU
新細明體:PMingLiU


限制使用 Document Server 的 ownCloud 主機:

# vi /etc/onlyoffice/documentserver/default.json
# systemctl restart supervisor.service



ownCloud 整合 OnlyOffice 設定部份:
ownCloud 安裝 OnlyOffice Client:
# cd /var/www/owncloud/apps/
# git clone https://github.com/ONLYOFFICE/onlyoffice-owncloud.git onlyoffice
# chown -R www-data:www-data onlyoffice

切換到 owncloud web 設定:
啟用 OnlyOffice Plug-in
設定 OnlyOffice Document Server 位址:

備註:
1.如使用 SSL 連線 ownCloud,在開啟文件編輯時,會被擋掉;出現錯誤訊息:
ONLYOFFICE cannot be reached. Please contact admin

原因是: 沒有有效的 SSL 認證

Edge、IE 按 <檢視所有內容> 或 Chrome 按 <載入不安全的指令碼>,就可以啟文件編輯畫面。

2.亂碼問題
將字型放入 Document Server 後,文件檔案裡還是有亂碼出現時,可以試著更改字型。有些亂碼可以借由變更字型獲得解決。





2017年6月21日 星期三

ownCloud 雲端硬碟 整合 Windows(AD)、Samba(AD) LDAP

安裝 php LDAP module
# apt-get install php7.0-ldap

安裝 ownCloud LDAP module
尋找 < LDAP user and group backend > 按 install

安裝後,按右上角的 admin 裡的 <設定>
會在左側多了一項< User Authentication >
看到測試連線 AD LDAP 的提示亮綠色,表示已正常連線 AD LDAP 了。

ownCloud 登入畫面輸入 AD 帳號、密碼(不須 Domain Name)






Ubuntu 16.04 安裝 ownCloud 雲端硬碟

ownCloud 雲端硬碟支援多種作業系統:如 Windows, IOS, Android


安裝相關套件
# apt-get update
# apt-get install -y php libapache2-mod-php php7.0-mysql php7.0-zip php7.0-dom php7.0-xml php7.0-gd php7.0-curl php7.0-mb php7.0-fpm php-apcu php-intl mysql-server apache2
# /etc/init.d/apache2 restart && /etc/init.d/mysql restart

下載 ownCloud 套件
# wget https://download.owncloud.org/community/owncloud-10.0.2.tar.bz2
# tar -xf owncloud-10.0.2.tar.bz2
# mv owncloud /var/www/
# mkdir /ownCloud_data    //存放使用者檔案資料
# chown -R root:www-data /var/www/owncloud
# chown -R www-data:www-data /var/www/owncloud/{apps,config}
# chown -R www-data:www-data /ownCloud_data

修改 /etc/apache2/sites-available/000-default.conf 變更 DocumentRoot
# vi /etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www/owncloud

# /etc/init.d/apache2 restart

開啟瀏覽器連到 ownCloud 伺服器

http://owncloud_ip/


依畫面設定:
ownCloud 強烈建議將 資料目錄 移出 WEB 根目錄下:

根據 ownCloud 建議,做以下處理:
1.移動 data 目錄
移動 data 目錄後,修改 /var/www/owncloud/config/config.php
'datadirectory' => '/var/www/owncloud/data'
修改為新的位置:
'datadirectory' => '/ownCloud_data'

2.修改 owncloud DB 的 oc_accounts、oc_storages 兩個 Table 相關欄位

3.安裝 redis-server 及連結 php
# apt-get install -y php7.0-dev redis-server unzip
# wget https://github.com/phpredis/phpredis/archive/php7.zip -O phpredis.zip
# unzip -o phpredis.zip && mv phpredis-* phpredis && cd phpredis && phpize && ./configure && make && make install
# mkdir -p /etc/php/mods-available
# touch /etc/php/mods-available/redis.ini && echo extension=redis.so > /etc/php/mods-available/redis.ini
# ln -s /etc/php/mods-available/redis.ini /etc/php/7.0/apache2/conf.d/redis.ini
# ln -s /etc/php/mods-available/redis.ini /etc/php/7.0/fpm/conf.d/redis.ini
# ln -s /etc/php/mods-available/redis.ini /etc/php/7.0/cli/conf.d/redis.ini

4.重啟相關服務
# /etc/init.d/php7.0-fpm restart && /etc/init.d/apache2 restart

測試 redis-server 安裝是否正常運作"
# php -r "if (new Redis() == true){ echo \"OK \r\n\"; }"

5.修改 /var/www/owncloud/config/config.php 設定 filelocking
# vi /var/www/owncloud/config/config.php
加入以下設定:
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',

  'redis' => array(
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0.0,
    'password' => '',  //Optional, if not defined no password will be used.
  ),

6.cron 排程工作
# crontab -u www-data -e
*/15  *  *  *  * /usr/bin/php -f /var/www/owncloud/cron.php

7.啟用 SSL
# a2enmod ssl
# mkdir /etc/apache2/ssl
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
# vi /etc/apache2/sites-available/000-default.conf
<VirtualHost *:443>
      SSLEngine on
      DocumentRoot /var/www/owncloud

      <IfModule mod_headers.c>
        Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
      </IfModule>

      SSLCertificateFile /etc/apache2/ssl/apache.crt
      SSLCertificateKeyFile /etc/apache2/ssl/apache.key
</VirtualHost>

# cd /etc/apache2/mods-enabled/
# ln -sf ../mods-available/headers.load headers.load
# /etc/init.d/apache2 restart

8.其他額外設定值,可參考 /var/www/owncloud/config/config.sample.php

9.其他 Plug-in https://apps.owncloud.com/





2017年6月19日 星期一

Let's Encrypt 免費 SSL 憑證設定(Nginx,Apache,Postfix,Dovecot)

Let's Encrypt:

Let's Encrypt 每張免費憑證期限是90天,但廠商提供了自動更新 script,可排程檢查 SSL 期限並自動更新 SSL 憑證。

須停用 WEB 服務:
systemctl stop nginx.service (Let's Encrypt 程式會模擬  web 給 SSL 發行的網站確認用,80 port 不能被使用,所以要停 web)

下載、安裝  Let's Encrypt 套件:
CentOS:
# yum install epel-release
# yum install certbot

Ubuntu:
$ sudo apt install -y git bc wget
$ sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt (安裝 Let's Encrypt 程式到 /opt/letsencrypt)


# /opt/letsencrypt/certbot-auto certonly --standalone --email xxx@example.com --agree-tos -d example.com (可利用 -d 加多個Domain)


憑證檔案 :
安裝完的憑證會依照申請的 domain 當作資料夾名稱放到 /etc/letsencrypt/live/ 目錄下
如果同時申請了 example.com 與 www.example.com,那麼憑證檔案就會分別放在 /etc/letsencrypt/live/example.com/ 及 /etc/letsencrypt/live/www.example.com/ 目錄下

憑證檔案分別會有 4 個
檔案名稱說明
cert.pem申請網域的憑證
chain.pemLet's Encrypt 的憑證
fullchain.pemcert.pem 及 chain.pem 合併檔案
privkey.pem申請網域的憑證密鑰

設定 nginx 使用 SSL 憑證:
vi /etc/nginx/templates/ssl.tmpl
內容:
server {
    # 設定憑證檔案
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    .......
}

設定 nginx 80 port 自動轉址導向 SSL 443 port
# vi /etc/nginx/sites-enabled/00-default.conf
內容:
server {

     location ~ /\.well-known\/acme-challenge {
      allow all;
    }

    if ($request_uri !~ /\.well-known) {
      return 301 https://$host$request_uri;
    }
}

設定 Postfix 使用 SSL 憑證:
# vi /etc/postfix/main.cf
修改:
# Force TLS-encrypted SASL authentication.
smtpd_tls_auth_only = yes
smtpd_tls_security_level = may
smtpd_tls_loglevel = 0
smtpd_tls_key_file = /etc/letsencrypt/live/example.com/privkey.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/example.com/cert.pem
smtpd_tls_CAfile = /etc/letsencrypt/live/example.com/fullchain.pem
tls_random_source = dev:/dev/urandom

設定 dovecot 使用 SSL 憑證:
# vi /etc/dovecot/dovecot.conf
修改:
ssl_cert = </etc/letsencrypt/live/example.com/cert.pem
ssl_key = </etc/letsencrypt/live/example.com/privkey.pem
ssl_ca = </etc/letsencrypt/live/example.com/fullchain.pem


重啟相關 Service:
# systemctl restart nginx.service postfix.service dovecot.service

測試自動更新憑證:


/opt/letsencrypt/certbot-auto renew --dry-run

加入 Crontab 排程執行憑證更新 :
crontab -e
設定每個禮拜一的凌晨 2:30 (排程自訂)進行一次憑證的檢查及更新
30 2 * * Mon /opt/letencrypt/certbot-auto renew >> /var/log/le-renewal.log; systemctl restart nginx.service postfix.service dovecot.service


這樣就有了一個半永久的 SSL 憑證


建立 Let's Encrypt 設定檔 :
複製在原本 letsencrypt 目錄下的範例設定檔 /opt/letsencrypt/examples/cli.ini
cp /opt/letsencrypt/examples/cli.ini /usr/local/etc/le-renew-webroot.ini

編輯自訂設定檔:
vi /usr/local/etc/le-renew-webroot.ini
修改:
rsa-key-size = 4096
email = xxxxx@example.com
domains = example.com, example1.com
webroot-path = /var/www/html/    # www預設目錄


使用 Script 自動更新憑證:
下載憑證更新 shell script,並將 Script 設定為可執行檔案 :
apt-get install -y curl

curl -L -o /usr/local/sbin/le-renew-webroot https://gist.githubusercontent.com/thisismitch/e1b603165523df66d5cc/raw/fbffbf358e96110d5566f13677d9bd5f4f65794c/le-renew-webroot

chmod +x /usr/local/sbin/le-renew-webroot

le-renew-webroot Script 讀取 /usr/local/etc/le-renew-webroot.ini 設定資料並進行憑證更新,若憑證還有 30 天以上才過期,則不更新憑證。

手動執行,測試 shell script 更新憑證 :
/usr/local/sbin/le-renew-webroot

Checking expiration date for example.com...
The certificate is up to date, no need for renewal (89 days left).
...........................................

如有需要可強制更新憑證:
/opt/letsencrypt/certbot-auto renew --force-renew 



設定 Apache 使用 SSL 憑證:
1.確認 Apache httpd.conf 有載入 mod_ssl 模組,如果沒有安裝 SSL 模組:
yum install -y mod_ssl openssl

2.修改要套件 SSL 的網頁 conf 設定檔:
Apache 設定使用 SSL 憑證:
<VirtualHost *:443>
  ServerName example.com
  DocumentRoot /var/www/html/example

  SSLEngine on
  SSLCertificateFile    /etc/letsencrypt/live/example.com/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/example.com/fullchain.pem

  <Directory "/var/www/html/example">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

3.設定 80 port 轉址 443 port:
<VirtualHost *:80>
  ServerName example.com
  DocumentRoot /var/www/html/example
  Redirect permanent / https://example.com/
  <Directory "/var/www/html/example">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>




ManageEngine EventLog Analyzer版本更新步驟

更新檔下載位址: Upgrade to Latest Version of EventLog Analyzer Build (manageengine.com) 先將下載的更新檔上傳到主機裡,再進行下列動作。 切換到 ManageEngine EventLog Analyzer ...