# 五、進階設定

#### (1)設定使用對外服務位置

本文件前面所描述之使用情境，皆預設在「<span style="color:red;">**內網 IP 環境**</span>」，若機關佈署的環境開放以下二種情境者，需額外進行進階的設定，二種情境如下：

1. 使用真實 IP 對外開放服務(例如：117.56.68.133)
2. 使用 FQDN 做為服務主機名稱(例如：odf.nat.gov.tw)

請進入 modaodfweb 主機上，修改 `/etc/modaodfweb/modaodfweb.xml` 的內容，找到以下這段：

```
<wopi desc="Allow/deny wopi storage. Mutually exclusive with webdav." allow="true">
<host desc="Regex pattern of hostname to allow or deny." allow="true">localhost</host>
<host desc="Regex pattern of hostname to allow or deny." allow="true">10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}</host>
<host desc="Regex pattern of hostname to allow or deny." allow="true">172\.1[6789]\.[0-9]{1,3}\.[0-9]{1,3}</host>
<host desc="Regex pattern of hostname to allow or deny." allow="true">172\.2[0-9]\.[0-9]{1,3}\.[0-9]{1,3}</host>
<host desc="Regex pattern of hostname to allow or deny." allow="true">172\.3[01]\.[0-9]{1,3}\.[0-9]{1,3}</host>
<host desc="Regex pattern of hostname to allow or deny." allow="true">192\.168\.[0-9]{1,3}\.[0-9]{1,3}</host>
<host desc="Regex pattern of hostname to allow or deny." allow="true">117\.56\.68\.133</host>
<host desc="Regex pattern of hostname to allow or deny." allow="true">odf\.nat\.gov\.tw</host>
<host desc="Regex pattern of hostname to allow or deny." allow="false">192\.168\.1\.1</host>
<max_file_size desc="Maximum document size in bytes to load. 0 for unlimited." type="uint">0</max_file_size>
</wopi>
```

請加入上述 117\.56\.68\.133 與 odf\.nat\.gov\.tw 那二行的範例內容，儲存後跳出，重新啟動 modaodfweb 的服務即可。

`# systemc restart modaodfweb`

另外開放對外可連到這台主機以下的連接埠號：80、9980

就可正常使用 ODF 雲端編輯器。

#### (2)使用 ODF API 的額外設定

若要使用 ODF API 進行作業，因自 2.X 版開始已將 ODF API 伺服器整合至 ODF 雲端編輯元件中，必須在其設定檔中進行額外的設定才能正常運作，請進入 modaodfweb 主機上，修改 `/etc/modaodfweb/modaodfweb.xml` 的內容，找到以下這段：

`<server_name desc="External hostname:port of the server running modaodfweb. If empty, it's derived from the request (please set it if this doesn't work). Must be specified when behind a reverse-proxy or when the hostname is not reachable directly." type="string" default=""></server_name>`

請在 `</server_name>` 前，`<……default=””>` 後插入此 ODF 雲端編輯元件的完整 URL（一般情況下需包含連接埠號，例如192.168.3.1:9980），然後儲存後跳出，重新啟動 modaodfweb 的服務即可。

`# systemc restart modaodfweb`

#### (3)設定啟用 SSL 憑證

若服務的主機運作在 SSL 協定上時，則可透過以下設定方式啟動 SSL，憑證申請的流程可參考 GCA 資證申請作業流程。

[https://gcp.nat.gov.tw/](https://gcp.nat.gov.tw/)

申請好了之後，請將相關的憑證上傳至 modaodfweb 主機上，建議可將憑證檔案放在 `/etc/httpd/ssl` 目錄下。

- Apache  Web Server 的設定

先安裝 ssl 套件

```
# yum install -y mod_ssl
# vim /etc/httpd/conf.d/ssl.conf
```

修改以下三行（請依照實際的路徑設定）

```
SSLCertificateFile /etc/httpd/ssl/certificate.crt
SSLCertificateKeyFile /etc/httpd/ssl/private.key
SSLCACertificateFile /etc/httpd/ssl/ca_bundle.crt
```

存檔後，重啟服務。

`# systemctl restart httpd`

- ODF文件Web應用元件主程式

請進入 modaodfweb 主機上，修改 /etc/modaodfweb/modaodfweb.xml 的內容，找到以下這段：

`<enable type="bool" desc="Controls whether SSL encryption is enable (do not disable for production deployment). If default is false, must first be compiled with SSL support to enable." default="true">true</enable>`

請將 `</enable>` 前由原本的 false 改為 true。

另外再指定以下三個憑證位置（路徑可與上述 httpd 的 SSL 憑證相同），例子如下：

```
<cert_file_path desc="Path to the cert file" relative="false">/etc/httpd/ssl/certificate.crt</cert_file_path>
<key_file_path desc="Path to the key file" relative="false">/etc/httpd/ssl/private.key</key_file_path>
<ca_file_path desc="Path to the ca file" relative="false">/etc/httpd/ssl/ca_bundle.crt</ca_file_path>
```

儲存後跳出，重新啟動 modaodfweb 的服務即可。

`# systemc restart modaodfweb`

依照上述設定，正常就可以使用以下的連結使用服務：

https://yourhostname:9980 → 為「ODF文件Web應用元件主程式」（一般安裝說明如第貳章所示）測試服務位置，出現OK字樣，並且瀏覽器端會顯示為合法憑證。

https://yourhostname/odfweb → 為預設「ODF文件Web應用元件網路儲存空間軟體」（一般安裝說明如第參章所示）進入點，此時可成為加密型態。