跳到主要內容

SmartOS安裝Self-Gen SSL憑證

下面的設定是在MiCloud SmartOS上的設定,版本為SmartOSPlus64:3.2.0
如果需要在其他版本實作,則需要考慮apache server的設定檔案位置

原則上pkgin install安裝的時候可以看到設定說明...

STEP1: 產生Self-Gen SSL金鑰

[root@SmartOS /opt/local/share]# cd /opt/local/etc/httpd/
[root@SmartOS /opt/local/etc/httpd]# openssl genrsa -des3 -out server.key 1024                                                                                                  
Generating RSA private key, 1024 bit long modulus
......++++++
......................++++++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
[root@SmartOS /opt/local/etc/httpd]# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:TW     
State or Province Name (full name) [Some-State]:Taipei
Locality Name (eg, city) []:Taiwan
Organization Name (eg, company) [Internet Widgits Pty Ltd]:********
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:********
Email Address []:***********

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:       
An optional company name []:
[root@SmartOS /opt/local/etc/httpd]# cp server.key server.key.org
[root@SmartOS /opt/local/etc/httpd]# openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key
[root@SmartOS /opt/local/etc/httpd]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=TW/ST=Taipei/L=Taiwan/O=MiCloud/CN=MiCloud/emailAddress=service@micloud.tw
Getting Private key
[root@SmartOS /opt/local/etc/httpd]#

STEP2: 編輯Virtual Host資訊

# vi /opt/local/etc/httpd/virtualhosts/test.conf
<VirtualHost _default_:443>
SSLEngine On
SSLCertificateFile /opt/local/etc/httpd/server.crt
SSLCertificateKeyFile /opt/local/etc/httpd/server.key
ServerName your.ip.or.domaonname
DocumentRoot /opt/local/share/httpd/htdocs
</VirtualHost>

STEP3: 測試連線

瀏覽器連線:https://your.ip.or.domaonname/

這個網誌中的熱門文章

Oracle LISTAGG

同事介紹的一個Oracle的好用查詢:LISTAGG
SELECT A.GROUP_ID,A.KEY, LISTAGG(A.VALUE,'; ')WITHINGROUP(ORDERBYA.VALUE)as GG  fromSYS_PROPERTIESaGROUP byA.GROUP_ID,A.KEY
LISTAGG可以將group後的結果會總顯示於一個欄位 上述SQL原本A.VALUE會是一個row一個row的排列 使用LISTAGG之後,可以將A.VALUE顯示在同一個row中 並且可以指定間隔符號(在此設定為';') 針對某一些報表查詢非常有用唷 :D

使用 minikube 輕鬆上手 kubernetes

安裝minikube
macOS只需要透過brew即可快速安裝...
brew cask install minikube
Linux環境可以直接下載執行檔,放到環境變數可以吃到的路徑即可...
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && \ chmod +x minikube && \
sudo mv minikube /usr/local/bin/
Windows的下載網址如下: https://storage.googleapis.com/minikube/releases/latest/minikube-windows-amd64.exe
如果您的kubectl尚未安裝,可以直接使用google cloud sdk來安裝:
curl https://sdk.cloud.google.com | bash
gcloud components install kubectl
安裝完成後,原則上minikube會在本地端加入minikube的k8s context,我們可以透過下面指令來使用該context…
kubectl config use-context minikube
然後,可檢查一下您的minikube node是否正常運作....

新一代LB - Traefik

新一代LB-Traefik Traefik突破以往我們對loadbalancer的觀點,他是一套直接與docker整合的loadbalancer套件...透過Traefik,我們可以使用label的方式將後面啟動的dockerinstance掛載到loadbalancer中,且無需重新啟動Traefik,可直接生效... Traefik基本介紹 Traefik是以動態重載新加入的dockerinstance的方式來替有附加相同domainlabel的dockerinstance建立網路附載平衡的關聯...因此,設定上,與一般我們建立reverseproxy的過程剛好相反(一般我們會先建立服務,再建立reverseproxy將服務串連起來)... Step1-建立Traefik服務 下面我們用官方的composefile來說明... File:docker-compose.yaml version: '2' services: proxy: image: traefik command: --api --docker --docker.domain=docker.localhost --logLevel=DEBUG networks: - webgateway ports: - "80:80" - "8080:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock - /dev/null:/traefik.toml networks: webgateway: driver: bridge 其中traefik啟動時候,我們需要指定docker.domain來告訴taefik要聆聽的domain是哪一個,然後要事先開啟對應的port,讓外部服務可以連到traefik...,另外,我們將dockersocket掛載進來,這是必要的設定,讓traefik可以透過dockersocket來操控一些東西...,最後,traefik.toml檔案,我們保留空的,讓treafik自己建立... 啟動: docker-compose -f docker…