[Linux] Let’s Encrypt 換成 ZeroSSL

export ACCOUNT_EMAIL="OOO@XXX.XXX"
/usr/local/acme.sh/acme.sh --set-default-ca --server zerossl

如果站點沒有順利更換過去,乾脆vhost重建,再重選需要 SSL

  1. sudo -i
  2. lnmp vhost del XXX.xxx.com.tw
  3. lnmp vhost add XXX.xxx.com.tw
  4. 添加301轉址進去 conf
server {
	listen	80;
	server_name yourname.com;
	return 301 https://$server_name$request_uri;
補充:
# 不好的方法:
rewrite ^/(.*)$ http://example.com/$1 permanent;
# 好的方法:
rewrite ^ http://example.com$request_uri? permanent;
# 更好的方法:
return 301 http://example.com$request_uri;

[Python] 設定密碼來取代token

Starting at notebook version 5.0, you can enter and store a password for your notebook server with a single command. jupyter notebook password will prompt you for your password and record the hashed password in your jupyter_notebook_config.json.

  1. 打開 jupyterlab,新建一個Notebook,然後開一個cell輸入:
from notebook.auth import passwd
passwd()
  1. 輸入兩次密碼後,重開 docker,之後就可以使用密碼取代token。
    記得 docker restart ,容器重開。

常用指令補充:

1. Docker,重開機後,當下次想進去容器使用命令列時:

$ docker exec -it miniconda /bin/bash
可以開第二個終端機,進去進行pip安裝套件等工作
-i:互動模式
-t:終端機
-d:在背景執行

2. Docker,進去容器裡面設定conda相關套件:

開始設定環境(假如是linux的話,可以輸入以下指令即可:)

# 啟動環境
$ conda activate 999

# 關閉環境
$ conda deactivate 

3. Docker,get the notebook token from the logs:

docker logs --tail 3 notebook

[Linux] UniFi Controller and Docker

簡單做個筆記:

以下都是使用一般user權限,不用root。畢竟一開始也有將某個user開通docker使用權限了。(參考上篇)

$ cd /home
$ mkdir -p unifi/data
$ mkdir -p unifi/log

# 測試指令:
$ docker run --rm --init -p 8080:8080 -p 8443:8443 -p 3478:3478/udp -e TZ='Asia/Taipei' -v /home/unifi:/unifi --name unifi jacobalberty/unifi:latest
 
     --rm:其用途就是在我們執行完指令後,可以不用再下 docker rm 的指令去刪除容器,直接在執行完指令後, Docker可以自動幫我們刪除容器。
     latest:本來要裝穩定版,但原本就有運作的UniFi Controller,他已經升級到最新版本,所以這邊也跟著抓最新版本
 

# 實際上線指令:
$ docker run -d \
     --restart=unless-stopped \
     --net=host \
     --name=unifi \
     -e TZ='Asia/Taipei' \
     -e RUNAS_UID0=false \
     -v /home/unifi:/unifi \
     jacobalberty/unifi:latest

     --net=host:是為了允許L2發現。如果不需要L2發現,只需映射Port即可。
     -e RUNAS_UID0 改成 false,讓 Controller 不要用 root 身份運作。


# 未來我該如何升級呢?
 $ docker pull jacobalberty/unifi:stable
 $ docker stop unifi
 $ docker rename unifi unifi.save

然後再做一次run指令,跟上面相同
 $  docker run -d \
     --restart=unless-stopped \
     --net=host \
     --name=unifi \
     -e TZ='Asia/Taipei' \
     -e RUNAS_UID0=false \
     -v /home/unifi:/unifi \
     jacobalberty/unifi:latest

[Linux] 在ubuntu安裝Docker的一些筆記

環境

Ubuntu 20.04

安裝 docker

$ sudo apt-get install docker.io

檢查 docker 服務有無正常啟動

$ service docker status

如果沒意外的話會在前面幾行看到:Active:active(running)

將自己使用者帳號加入 docker 群組

$ sudo usermod -aG docker <username>

這個動作主要是因為權限的關係,如果沒有加這個,會導致普通使用者沒權限使用 Docker。

登出後再重新登入

$ docker version

會出現 Client、Server 的訊息,但如果最下面出現了:

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

這就是可能因為沒做第三個步驟,通常是權限的問題。


閱讀全文〈[Linux] 在ubuntu安裝Docker的一些筆記〉