2021年11月18日 星期四

Ubuntu18.04 Route Table

前言:

  因主機有雙網卡,一張對外,一張對內,原本是用Route指令設定,但可能是我比較笨,沒找到可以永久寫入的指令,因此重開機之後,加的Route Rule會不見,後來改設定到Netplan中就好了。


    ens192:

            addresses:

            - 192.168.0.138/24

            - 192.168.10.15/24

            routes:

                    - to: 172.16.1.1/24      (你要溝通的網段)

                      via: 192.168.0.254    (可以到那個網段的GW)

                      metric: 10                  (Route Table的權值,可參考網路上教學)

            dhcp4: false

            nameservers:

                addresses: []

                search: []


參考資料:https://www.twblogs.net/a/5ca19a96bd9eee5b1a06a6cf

2021年5月3日 星期一

Ubuntu Apache2.4網站資安修補

  一、Directory listings

        修補方式:

        編輯這個檔案/etc/apache2/apache2.conf。

        sudo vi /etc/apache2/apache2.conf

        找到這個內容:

        <Directory /var/www/>

        Options Indexes FollowSymLinks

        AllowOverride None

        Require all granted

</Directory>

        修改此行

        Options Indexes FollowSymLinks

        修改成

        Options -Indexes +FollowSymLinks

        重啟Apache2

        sudo systemctl restart apache2

參考資料:

https://www.vultr.com/docs/how-to-disable-directory-browsing-on-apache


二、TLS 1.0 enabled

        修補方式:

       編輯這個 /etc/apache2/mods-available/ssl.conf 檔案。

        找到以下此行設定,加入你不想要開放的,如SSL3.0、TLS1.0等。

        SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1

        重啟Apache2

        sudo systemctl restart apache2

參考資料:

https://blog.ijun.org/2017/10/disable-tls-10-and-11-in-apache-24.html


三、Clickjacking: X-Frame-Options header missing

        修補方式:

        找到這個檔案/etc/apache2/conf-available/security.conf

        將此行的註解取消

        #Header set X-Frame-Options: “SAMEORIGIN”

        取消後,執行此一指令

        a2enmod headers

        重啟Apache2

        sudo systemctl restart apache2

參考資料:

http://programmer.hsinchi.info/1999


四、Cookies with missing, inconsistent or contradictory properties、Cookies without HttpOnly flag set、Cookies without Secure flag set

        修補方式:

        執行指令

        a2enmod rewrite

        a2enmod headers

        編輯此一檔案/etc/apache2/apache2.conf

        如果只跑HTTP,請加入此一行

        Header edit Set-Cookie ^(.*)$ $1;HttpOnly

        如果只跑HTTPS,請加入此一行

        Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure

        重啟Apache2

        sudo systemctl restart apache2

參考資料:

https://techexpert.tips/apache/apache-enable-httponly-secure-headers/


五、HTTP Strict Transport Security (HSTS) not implemented

        修補方式:

        a2enmod headers

        修改/etc/apache2/sites-enabled/000-default-ssl.conf(請根據自已的環境更改檔案)

        找到<VirtualHost *:443></VirtualHost> 這個區段,在其中加入這行設定:

        Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

參考資料:

https://websiteforstudents.com/lesson-39configure-http-strict-transport-security-hsts-on-apache2/       


        


2021年1月27日 星期三

手動申請Let's Encrypt憑證記錄

 前言:

  申請Let's Encrypt憑證的教學很多,而且大部份都是集中在自動結合Apache等網頁伺服器,或是提供憑證申請的平台,但是因為我的主機是利用Synology NAS中的Web服務來供內網使用,所以不想要讓外部網路能連線到NAS,Synology雖然有提供Let's Encrypt服務,但是都會被我的防火牆阻擋,為了不想要讓使用者瀏灠時,出現憑證不安全的訊息,只好自已手動申請了,一開始是用SSL For Free平台,後來跟ZERO SSL合併,ZERO SSL現在一個免費帳號只提供三個網址,之後就得付費,為了省錢(公司應該不會想要付這筆錢),只好自已手動作了

  我是利用Centos7安裝Certbot來處理的,Centos7要先安裝epel-release:

yum install epel-release

  安裝Certbot:

yum install certbot

因為我們公司自已有DNS主機,所以我沒有跟一些有提供Let's Encrypt的DNS服務商利用他們的平台來自動提供驗證,我是用自已的DNS主機作驗證的。

手動產生憑證指令:

certbot -d example.com  --manual --preferred-challenges dns certonly --server https://acme-v02.api.letsencrypt.org/directory

說明一下,-d後面是要輸入你要的網址,你也可以申請萬用字元的網址,那就是*.example.com,

另外要留意的是--preferred-challenges,因為我是要用DNS驗證,所以後面是帶dns,如果你要用別的方式,就不能用dns。

在驗證的過程中,會要你輸入一組Mail,建議就是利用公司的,之後會再有兩個問題,就按Y就好了,之後會出現這個畫面:


這時候要就要把_acme-challenge.example.com這個網址及它的Value值加到DNS Record中:

_acme-challenge.example.com.       IN      TXT     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

如果你是自架的DNS Server,要記得網址後面的那個(.)點,我之前就常卡死在這。
加完之後,重啟DNS服務就可以作驗證了。重新Reload Dns服務就能驗證了。

systemctl reload named

驗證完之後,它就會在/etc/letsencrypt/live/中產出一個你申請網址的資料夾,裡面就會有你要的憑證檔再自已人工上傳就可以了。

每90天手動更新憑證指令:

certbot certonly -d example.com --manual --preferred-challenges dns


參考網址:
Certbot安裝:https://www.opencli.com/linux/rhel-centos-install-certbot-get-lets-encrypt-certs
Certbot自產憑證指令:https://www.ichiayi.com/wiki/tech/ssl_letsencrypt
Certbot原廠文件:https://certbot.eff.org/docs/using.html#manual


OpenProject專案匯出中文無法顯示問題

 OpenProject可以匯出專案成以下格式: 我OpenProject是架設在Ubuntu 20.04上,查了一下OpenProject處理匯出的功能,從網路上找到這篇文章: https://feifacunzai.github.io/2022/11/29/OpenProje...