發表文章

目前顯示的是 8月, 2018的文章

[Docker] ls: cannot open directory .: Permission denied 解決方式

今天要將container 裡面的檔案路徑mapping到實體主機的檔案路徑 docker run -it -v /home/user1/storage:/storage centos /bin/bash 時,在container裡的storage下ls卻出現 ls: cannot open directory .: Permission denied ,以下為解決方法: 環境:Linux 解決方式: 在host和container分別查看id -Z: [root@centos-minion share]# id -Z unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [root@centos-minion share]# ls -ldZ /home/share drwxr-xr-x. root root unconfined_u:object_r:home_root_t:s0 /home/share The container: [root@4ccce73bed9d share]# id -Z id: --context (-Z) works only on an SELinux-enabled kernel [root@4ccce73bed9d share]# ls -ldZ /home/share drwxr-xr-x. root root unconfined_u:object_r:home_root_t:s0 /home/share 原因就出在SELinux,可以輸入 docker run -it -v /home/share:/home/share:z 或 docker run -it -v /home/share:/home/share:Z 就解決囉! 參考來源: https://github.com/moby/moby/issues/14175

[LINUX]E: Unable to locate package sudo的解决方法

圖片
今天再用docker run container 的時候,要安裝軟體,遇到了bash: sudo: command not found的錯誤,,而又沒有/etc/sudoers.d文件,就是沒有安裝sudo命令,於是輸入apt-get install sudo又遇到E: Unable to locate package sudo的錯誤 unable to locate package sudo 以下是簡單解決方式: 環境:Linux 解決方式: 只要更新apt-get就好了,執行 apt-get update 補充: 一般會出現bash: sudo: command not found有兩個原因 1、首先查看/etc/sudores.d 文件是否存在,如果不存在就代表系統沒有安裝,則輸入 apt-get install sudo 2、如果/etc/sudores.d 文件存在,表示系統已經安裝,只要配置環境即可,輸入 export PATH=/usr/local/bin 參考資料: CSDN

[IE] IE瀏覽器出現 Promise is undefined

IE有雷呀!!! 今天客戶突然說他用IE開網頁無法瀏覽,我實際開才發現,乾!!真的耶!! 開啟偵錯過去竟然跟我說Promise is undefined ,而其他瀏覽器都可以正常預覽網頁,以下提供解決方式 測試瀏覽器:IE11 解決方式: 引入 bluebird 檔案,bluebird是 super high-performance Promise library,加入後就可以正常運作了 <script type="text/javascript">  var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE ");  if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))  document.write("<scr"+"ipt src='https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.5/bluebird.min.js'></scr"+"ipt>");  </script> 參考來源: promise-is-undefined-in-ie

[OPENVPN] Web Server Certificates延期

圖片
當OPENVPN Certificate快過期時,要怎麼辦? 簡單步驟幫vpn延期 環境:ubuntu SSL: Let’s Encrypt 步驟一:先將openvpn停止 sudo systemctl stop openvpnas 步驟二:建立SSL憑證 sudo certbot certonly 可參考 [Certbot / SSL] 簡單步驟教你生成 SSL 憑證 步驟三:上傳憑證 找到 fullchain.pem、cert.pem、privkey.pem 依照圖示位置上傳 web server configuration

[Certbot / SSL] 簡單步驟教你生成 SSL 憑證

圖片
今早收到了一封主旨為Let's Encrypt certificate expiration notice for domain "xxxxx"的信,才想到,哦!!原來SSL快過期了,來記錄下當初生成SSL的步驟 使用工具: CertBot 環境:Ubuntu 伺服器:Apache CertBot  是 Let’s Encrypt 推薦的憑證生成工具,但是 Let's Encrypt 提供的憑證有效期限每次只有 90 天的效期,若過期之後需要重新更新憑證方可繼續使用,以下為安裝的簡單三步驟 步驟一:下載 wget https://dl.eff.org/certbot-auto chmod a+x certbot-auto 步驟二:開始製作憑證 sudo certbot certonly certbot certonly 用 nginx 選擇 standalone,若是 apache 則選擇用 webroot 這裡出現3個選項,簡單介紹這三個項目 1.使用Apache模式 2.使用standalone模式: 預設standalone是使用443 port,需要暫時停止服務器正在占用443 port的process 3.使用webroot模式 如果需要在不影響服務器正常運作的情形下製作憑證,可以選擇webroot模式 步驟三:輸入驗證SSL的網址 enter in your domain name 完成:輸出憑證檔案 執行完的憑證會依照擬申請的domain當作資料夾名稱放到/etc/letsencrypt/live/ 目錄下,例如我申請了www.test.com,憑證檔案會放在/etc/letsencrypt/live/www.test.com/目錄下 憑證介紹: 檔案名稱 說明 cert.pem 申請網域的憑證 chain.pem Let's Encrypt 的憑證 fullchain.pem cert.pem 及 chain.pem 合併檔案 privkey.pem 申請網域的憑證密鑰 參考: Certbot自動化生成https憑證