由於內部裝了一台 Wifi AP , 設定時候, 沒有設定這一台的固定IP ( dchp取得的 )
所以透過 nmap 可以知道網段
# apt-get install namp
# nmap -sP 192.168.11.0/24
# nmap -sP 192.168.11.1-254
Nmap scan report for 192.168.11.1
Host is up (0.017s latency).
Nmap scan report for 192.168.11.2
Host is up (0.019s latency).
Nmap scan report for 192.168.11.4
Host is up (0.0095s latency).
Nmap scan report for 192.168.11.14
Host is up (0.000071s latency).
Nmap done: 256 IP addresses (4 hosts up) scanned in 6.74 seconds
@作業系統 (需要先sudo權限)
# nmap -O 192.168.11.1
@ 某台主機詳細資訊
# nmap -A -T4 192.168.11.1
Starting Nmap 6.40 ( http://nmap.org ) at 2016-04-28 17:21 CST
Nmap scan report for 192.168.11.1
Host is up (0.18s latency).
Not shown: 995 closed ports
PORT STATE SERVICE VERSION
53/tcp open domain ISC BIND 9.X
| dns-nsid:
|_ bind.version:
80/tcp open http Buffalo AirStation http config
| http-auth:
| HTTP/1.0 401 Unauthorized
|_ Basic realm=AirStation
|_http-methods: No Allow or Public header in OPTIONS response (status code 501)
|_http-title: UNAUTHORIZED
2601/tcp open zebra Quagga routing software
2602/tcp open zebra Quagga routing software
49152/tcp open upnp Intel UPnP reference SDK 1.2 (Linux 2.4.20; UPnP 1.0)
Service Info: OS: Linux; Device: WAP; CPE: cpe:/o:linux:linux_kernel:2.4.20
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.16 seconds
2016年4月28日 星期四
2016年4月26日 星期二
[DevOps] - 使用現成的服務來串接
最近使用上的心得 ,
看到某些網站上的"連絡我們" ,
是用一個網頁 sumbit 相關資訊出去後
串到Google Doc 表單 ~
想到很多事情都可以用現有的資源來作
ex.
新創團隊就很適合 , 去申請N個連續的 Gmail 個人帳號 , 透過申請網域後MX到某一台 postfix Server 去 Newalias 名稱即可
過程不用到半天 ~ 符合 devOps 精神 ...
看到某些網站上的"連絡我們" ,
是用一個網頁 sumbit 相關資訊出去後
串到Google Doc 表單 ~
想到很多事情都可以用現有的資源來作
ex.
新創團隊就很適合 , 去申請N個連續的 Gmail 個人帳號 , 透過申請網域後MX到某一台 postfix Server 去 Newalias 名稱即可
過程不用到半天 ~ 符合 devOps 精神 ...
2016年4月23日 星期六
[RDP] - Linux 套件 Rdesktop & Remmina
最近在AWS EC2 上裝了Windows ,
裡面 Run 起一支 Line Bot , 來發訊息
但因為使用了AutoHotKey ,
需要滑鼠的指標 ,
目前只能使用 RDP 協定連進去
由於工作環境是 Linux Ubuntu Like 桌面 , 所以找了兩套來作
1. Rdesktop , apt-get install rdesktop 安裝後, 直接輸入參數 , cmd 連接上去Windows RDP
2. Remmina , 安裝後 , 有比較完整的桌面應用視窗來操作跟紀錄相關使用過設定參數
都還不錯用 ><"
裡面 Run 起一支 Line Bot , 來發訊息
但因為使用了AutoHotKey ,
需要滑鼠的指標 ,
目前只能使用 RDP 協定連進去
由於工作環境是 Linux Ubuntu Like 桌面 , 所以找了兩套來作
1. Rdesktop , apt-get install rdesktop 安裝後, 直接輸入參數 , cmd 連接上去Windows RDP
2. Remmina , 安裝後 , 有比較完整的桌面應用視窗來操作跟紀錄相關使用過設定參數
都還不錯用 ><"
2016年4月20日 星期三
[Email] - 檢查不檔信的相關資訊
自己架設 Email Service 有時候都會遇到檔信件的問題
有些是 Gmail or Yahoo or Others 對方的信件管理 Policy
但有些是自己架設的時候需要檢查清楚的
1. 如果要寄給 @gmail , 那需要在自己的 DNS records 新增 SPF 紀錄
這個是讓 Gmail 確認你是網域服務的擁有者
2. 確認有Email Service Domain 有反解 PTR 紀錄 , 可向 VPS or ISP 申請
3. 去國際組查看一下 , IP or Domain 有沒有被列入黑名單
4. 檢查 Mail 內容 , 有些會檔信 ( 實際值要看對方的 Email Policy
5. Yahoo 信件收信的時候會過濾掉 Hyper Link
6. 再不行 ~ 就寫信給收信端的 Email Server Owner or Helper ><"
有些是 Gmail or Yahoo or Others 對方的信件管理 Policy
但有些是自己架設的時候需要檢查清楚的
1. 如果要寄給 @gmail , 那需要在自己的 DNS records 新增 SPF 紀錄
這個是讓 Gmail 確認你是網域服務的擁有者
2. 確認有Email Service Domain 有反解 PTR 紀錄 , 可向 VPS or ISP 申請
3. 去國際組查看一下 , IP or Domain 有沒有被列入黑名單
4. 檢查 Mail 內容 , 有些會檔信 ( 實際值要看對方的 Email Policy
5. Yahoo 信件收信的時候會過濾掉 Hyper Link
6. 再不行 ~ 就寫信給收信端的 Email Server Owner or Helper ><"
2016年4月19日 星期二
2016年4月18日 星期一
[VPS] - 當 Demo & Backup & 翻牆 Shadowsock ... etc Server
最近購買了一個小型的 VPS https://my.frantech.ca/cart.php
LV BuyVM-128MB , 兩年才 30 塊美金 , 很划算
機房在 Las Vegas美西 , 對於台灣的回應時間平均 17xms,
尚可接受 ><" , 不然日本或新加坡機房對台灣的 latency 比較友善
64 bytes from vps.raptornode.com (209.xx.xx.71): icmp_seq=1 ttl=54 time=172 ms
64 bytes from vps.raptornode.com (209.xx.xx.71): icmp_seq=2 ttl=54 time=174 ms
64 bytes from vps.raptornode.com (209.xx.xx.71): icmp_seq=3 ttl=54 time=173 ms
啟用Ubuntu 14.x
LV BuyVM-128MB , 兩年才 30 塊美金 , 很划算
機房在 Las Vegas美西 , 對於台灣的回應時間平均 17xms,
尚可接受 ><" , 不然日本或新加坡機房對台灣的 latency 比較友善
64 bytes from vps.raptornode.com (209.xx.xx.71): icmp_seq=1 ttl=54 time=172 ms
64 bytes from vps.raptornode.com (209.xx.xx.71): icmp_seq=2 ttl=54 time=174 ms
64 bytes from vps.raptornode.com (209.xx.xx.71): icmp_seq=3 ttl=54 time=173 ms
啟用Ubuntu 14.x
ssh 進去後 ,
沒有SWAP 檔 , 自己加上去 ,
因為要Run Nginx + php + MariaDB + Others
# free -m
total used free shared buffers cached
Mem: 128 113 14 66 0 105
# 新增 260M
# dd if=/dev/zero of=/var/swapfile bs=1024 count=261440
261440+0 records in
261440+0 records out
267714560 bytes (268 MB) copied, 1.34082 s, 200 MB/s
# /sbin/mkswap /var/swapfile
# /sbin/swapon /var/swapfile
# Reboot 開機自動啟用
1. 加到 /etc/fstab
2. /etc/rc.local 也可
2016年4月11日 星期一
[Ubuntu] - 切換作業環境語系 zh_TW.UTF-8 & 台北時間
因為使用購買了國外的 VPS , 預設裝起 Ubuntu 14.x
locale 都是英文 , 時間也是UTC
整各要切換回自己熟悉的工作環境 zh_TW.UTF-8
整各要切換回自己熟悉的工作環境 zh_TW.UTF-8
0. 調整時間 Asia/Taipei
# sudo dpkg-reconfigure tzdata
1. 新增語系定義
# sudo vim /var/lib/locales/supported.d/local
zh_TW.UTF-8 UTF-8
zh_TW BIG5
2. 產生語系檔案
# sudo locale-gen
3. 預設顯示語系 /etc/default/locale
# sudo vim /etc/default/locale
LANG="zh_TW.UTF-8"
LANGUAGE="zh_TW.UTF-8"
LC_NUMERIC="zh_TW.UTF-8"
LC_TIME="zh_TW.UTF-8"
LC_MONETARY="zh_TW.UTF-8"
LC_PAPER="zh_TW.UTF-8"
LC_NAME="zh_TW.UTF-8"
LC_ADDRESS="zh_TW.UTF-8"
LC_TELEPHONE="zh_TW.UTF-8"
LC_MEASUREMENT="zh_TW.UTF-8"
LC_IDENTIFICATION="zh_TW.UTF-8"
4. Logout --> Login ....
Done ~
2016年4月4日 星期一
[AWS] - S3 Buket 開放對外存取權限
之前使用 EC2 透過 S3 fuse 來 Mount Buket , 但這樣還是透過 EC2 的前端流量 + 內部流量 , 目前把 S3 Buket Mount 到前端的應用層 , 前端的圖層 Url 直接透過 S3 的 Web Hosting 來做使用讀取 Ex. https://xxxbuketname.s3.amazonaws.com/xxfilename.jpg
後台介面目前只能針對一各檔案去開放存取 , 如果要大量 , 需使用 Policy 政策來使用
官方文件有說明 : https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html
後台介面目前只能針對一各檔案去開放存取 , 如果要大量 , 需使用 Policy 政策來使用
官方文件有說明 : https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket
/*"]
}
]
}
2016年3月9日 星期三
[SMTP] - EDM Email Service 架設
最近有個需求是透過 AWS EC2 的一個 instance 來建照一台可以讓同各 subnet 的機器 ,
發 EDM 的 Email Server
採用 Ubuntu + Postfix 來處理
由於網域 xxx.com.tw 是讓 Godaddy 來管理 , 所以要先去 Godadday
新增一筆 MX
; For further information, please consult the BIND documentation
; located on the following website:
;
; http://www.isc.org/
;
; And RFC 1035:
;
; http://www.ietf.org/rfc/rfc1035.txt
;
; Please note that we do NOT offer technical support for any use
; of this zone data, the BIND name server, or any other third-
; party DNS software.
;
; Use at your own risk.
; SOA Record
xxx.com.tw. 600 IN SOA ns15.domaincontrol.com. dns.jomax.net (
2016030802
28800
7200
604800
600
)
; A Records
s1 600 IN A x.x.x.x
s2 600 IN A x.x.x.x
@ 600 IN A x.x.x.x
; CNAME Records
ftp 3600 IN CNAME @
www 3600 IN CNAME @
email 3600 IN CNAME @
; MX Records
@ 3600 IN MX 10 email.xxx.com.tw
; NS Records
@ 3600 IN NS ns16.domaincontrol.com
@ 3600 IN NS ns15.domaincontrol.com
# apt-get install postfix
# vim /etc/postfix/main.cf
myhostname = ip-172-31-30-43
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = email.xxx.com.tw, xxx.com.tw , localhost # 遇到任事的可以收
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.xx.xx.xx/20 # 准許本機 跟 172的網段可以寄信 , 後續也可以透過 iptables 或 Ec2 的 Security Group 來做
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/ # 採用一封信件一個檔案
驗證
# telnet xxx.com.tw 25
Trying 52.x.x.0...
telnet: connect to address 52.xx.xx.0: Connection timed out
要去打開 Ec2 的 Security Group 25 Port
Again
# telnet xxx.com.tw 25
Trying 52.xxx.xxx.0...
Connected to xxx.com.tw.
Escape character is '^]'.
220 ip-172-31-30-43 ESMTP Postfix (Ubuntu)
ehlo localhost
250-ip-172-31-30-43
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
# apt-get install mailutils
echo "Message Body" | mail -s "2Message Subject" fifi@xxx.com.tw
透過外部信件 ex. Gmail 寄給 fifi@xxx.com.tw
確認可以收 跟 送信
PS ( 如果寄到 gmail or Yahoo or other mail Server , 有時候要注意反解析網域寄信
不然會檔 , 自己用nslookup 來檢查 或 去跟 ISP 申請 )
收到信件的話會再帳號的 home下多一個 Maildir的目錄
裡面會有寄過來的信件 list
/home/xxx/Maildir
Maildir/
├── cur
├── new
│ ├── 1457580107.Vca01I6193bM206156.ip-172xxxx0-43
│ ├── 1457590218.Vca01I6194eM276640.ip-172xxxxs-43
│ └── 1457591864.Vca01I6194cM347714.ip-172xxxx-43
└── tmp
或看 mail log
# tail -f /var/log/mail.log
Mar 10 07:10:50 ip-172-31-30-43 postfix/smtpd[4088]: disconnect from mail-pf0-f174.google.com[209.85.192.174]
Mar 10 07:10:50 ip-172-31-30-43 postfix/smtp[4060]: F21726193B: to=<txxx@gmail.com>, orig_to=<xxx@xxx.com.tw>, relay=gmail-smtp-in.l.google.com[64.233.187.27]:25, delay=0.91, delays=0.01/0/0.35/0.55, dsn=2.0.0, status=sent (250 2.0.0 OK 1457593837 g24si4022733pfj.91 - gsmtp)
Mar 10 07:10:50 ip-172-31-30-43 postfix/qmgr[1515]: F21726193B: removed
@ Alias 新群組信件帳號 , 驗證
# vim /etc/aliases
# See man 5 aliases for format
postmaster: root
cs: xxx1@gmail.com,xxx2@gmail.com
# newaliases
echo "Message Body" | mail -s "2Message Subject" cs@xxx.com.tw
發 EDM 的 Email Server
採用 Ubuntu + Postfix 來處理
由於網域 xxx.com.tw 是讓 Godaddy 來管理 , 所以要先去 Godadday
新增一筆 MX
; For further information, please consult the BIND documentation
; located on the following website:
;
; http://www.isc.org/
;
; And RFC 1035:
;
; http://www.ietf.org/rfc/rfc1035.txt
;
; Please note that we do NOT offer technical support for any use
; of this zone data, the BIND name server, or any other third-
; party DNS software.
;
; Use at your own risk.
; SOA Record
xxx.com.tw. 600 IN SOA ns15.domaincontrol.com. dns.jomax.net (
2016030802
28800
7200
604800
600
)
; A Records
s1 600 IN A x.x.x.x
s2 600 IN A x.x.x.x
@ 600 IN A x.x.x.x
; CNAME Records
ftp 3600 IN CNAME @
www 3600 IN CNAME @
email 3600 IN CNAME @
; MX Records
@ 3600 IN MX 10 email.xxx.com.tw
; NS Records
@ 3600 IN NS ns16.domaincontrol.com
@ 3600 IN NS ns15.domaincontrol.com
# apt-get install postfix
# vim /etc/postfix/main.cf
myhostname = ip-172-31-30-43
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = email.xxx.com.tw, xxx.com.tw , localhost # 遇到任事的可以收
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.xx.xx.xx/20 # 准許本機 跟 172的網段可以寄信 , 後續也可以透過 iptables 或 Ec2 的 Security Group 來做
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/ # 採用一封信件一個檔案
驗證
# telnet xxx.com.tw 25
Trying 52.x.x.0...
telnet: connect to address 52.xx.xx.0: Connection timed out
要去打開 Ec2 的 Security Group 25 Port
Again
# telnet xxx.com.tw 25
Trying 52.xxx.xxx.0...
Connected to xxx.com.tw.
Escape character is '^]'.
220 ip-172-31-30-43 ESMTP Postfix (Ubuntu)
ehlo localhost
250-ip-172-31-30-43
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
或安裝 mail client tools
# apt-get install mailutils
echo "Message Body" | mail -s "2Message Subject" fifi@xxx.com.tw
透過外部信件 ex. Gmail 寄給 fifi@xxx.com.tw
確認可以收 跟 送信
PS ( 如果寄到 gmail or Yahoo or other mail Server , 有時候要注意反解析網域寄信
不然會檔 , 自己用nslookup 來檢查 或 去跟 ISP 申請 )
收到信件的話會再帳號的 home下多一個 Maildir的目錄
裡面會有寄過來的信件 list
/home/xxx/Maildir
Maildir/
├── cur
├── new
│ ├── 1457580107.Vca01I6193bM206156.ip-172xxxx0-43
│ ├── 1457590218.Vca01I6194eM276640.ip-172xxxxs-43
│ └── 1457591864.Vca01I6194cM347714.ip-172xxxx-43
└── tmp
或看 mail log
# tail -f /var/log/mail.log
Mar 10 07:10:50 ip-172-31-30-43 postfix/smtpd[4088]: disconnect from mail-pf0-f174.google.com[209.85.192.174]
Mar 10 07:10:50 ip-172-31-30-43 postfix/smtp[4060]: F21726193B: to=<txxx@gmail.com>, orig_to=<xxx@xxx.com.tw>, relay=gmail-smtp-in.l.google.com[64.233.187.27]:25, delay=0.91, delays=0.01/0/0.35/0.55, dsn=2.0.0, status=sent (250 2.0.0 OK 1457593837 g24si4022733pfj.91 - gsmtp)
Mar 10 07:10:50 ip-172-31-30-43 postfix/qmgr[1515]: F21726193B: removed
@ Alias 新群組信件帳號 , 驗證
# vim /etc/aliases
# See man 5 aliases for format
postmaster: root
cs: xxx1@gmail.com,xxx2@gmail.com
# newaliases
echo "Message Body" | mail -s "2Message Subject" cs@xxx.com.tw
2016年3月7日 星期一
[Ubuntu] - 移掉 Web Server Apache2 / Web Script PHP 相關資訊
@Before
root@ip-172-31-30-43:/etc/apache2# curl -LIv https://xxxx.com.tw
HTTP/1.1 200 OK
Date: Mon, 07 Mar 2016 08:02:12 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Content-Type: text/html
# vim /etc/apache2/conf-available/security.conf
ServerSignature Off
ServerTokens Prod
# vim /etc/php5/apache2/php.ini
expose_php = Off
# service apache2 restart
@ After
# curl -LI https://xxxx.com.tw
HTTP/1.1 200 OK
Date: Mon, 07 Mar 2016 08:05:29 GMT
Server: Apache
Content-Type: text/htm
2016年3月1日 星期二
[Ubuntu] - 乾淨的移除套件
列出安裝目錄
# dpkg -L nginx
乾淨的移掉 nginx 包含 /etc/ 跟 重裝
apt-get autoreove nginx # removes all but config file
apt-get purge nginx nginx-common nginx-full # removes everything
apt-get install nginx
# dpkg -L nginx
乾淨的移掉 nginx 包含 /etc/ 跟 重裝
apt-get autoreove nginx # removes all but config file
apt-get purge nginx nginx-common nginx-full # removes everything
apt-get install nginx
[AWS] - EC2 + S3
@ 到S3後台建立一個 Toky 的 Buket g1101
# sudo -s ( 小心使用 ><" )
# cd /root/
# apt-get install build-essential git libfuse-dev libcurl4-openssl-dev libxml2-dev mime-support automake libtool
# apt-get install pkg-config libssl-dev
# git clone https://github.com/s3fs-fuse/s3fs-fuse
# cd s3fs-fuse/
# ./autogen.sh
# ./configure --prefix=/usr --with-openssl
# make
# make install
# vim /etc/passwd-s3fs
#<AWS Access Key ID>:<AWS Secret Access Key>
AxxxxxxxxxxxxxxUA:vxxxxxxxxxxxxxxx+1
# chmod 640 /etc/passwd-s3fs
# mkdir /tmp/cache
# chmod 777 /tmp/cache
# mkdir /mnt/s3
# s3fs -o use_cache=/tmp/cache g1101 /mnt/s3
@ 查看 >< 有 256T
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 492M 12K 492M 1% /dev
tmpfs 100M 348K 99M 1% /run
/dev/xvda1 7.8G 1.6G 5.9G 21% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
s3fs 256T 0 256T 0% /mnt/s3
@ 如果要讓這個目錄可以讓 web User ( apache or www-data ) 存取到
要加上 allow_other
# s3fs -o allow_other,use_cache=/tmp/cache g1101 /mnt/s3
@ 自動開機 mount 加到 fstab or 寫到 /etc/rc.local
# vim /etc/fstab
s3fs#mybucket /mnt/s3 fuse allow_other,use_cache=/tmp/cache 0 0
@ Umount S3 Drive
# fusermount -u /mnt/s3
# sudo -s ( 小心使用 ><" )
# cd /root/
# apt-get install build-essential git libfuse-dev libcurl4-openssl-dev libxml2-dev mime-support automake libtool
# apt-get install pkg-config libssl-dev
# git clone https://github.com/s3fs-fuse/s3fs-fuse
# cd s3fs-fuse/
# ./autogen.sh
# ./configure --prefix=/usr --with-openssl
# make
# make install
# vim /etc/passwd-s3fs
#<AWS Access Key ID>:<AWS Secret Access Key>
AxxxxxxxxxxxxxxUA:vxxxxxxxxxxxxxxx+1
# chmod 640 /etc/passwd-s3fs
# mkdir /tmp/cache
# chmod 777 /tmp/cache
# mkdir /mnt/s3
# s3fs -o use_cache=/tmp/cache g1101 /mnt/s3
@ 查看 >< 有 256T
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 492M 12K 492M 1% /dev
tmpfs 100M 348K 99M 1% /run
/dev/xvda1 7.8G 1.6G 5.9G 21% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
s3fs 256T 0 256T 0% /mnt/s3
@ 如果要讓這個目錄可以讓 web User ( apache or www-data ) 存取到
要加上 allow_other
# s3fs -o allow_other,use_cache=/tmp/cache g1101 /mnt/s3
@ 自動開機 mount 加到 fstab or 寫到 /etc/rc.local
# vim /etc/fstab
s3fs#mybucket /mnt/s3 fuse allow_other,use_cache=/tmp/cache 0 0
@ Umount S3 Drive
# fusermount -u /mnt/s3
2016年2月26日 星期五
[AWS] - 手動 Clone EC2 Instance
主要是透過後台 Instance --> image --> Create image
然後自訂成 AMI , 也可以修訂此 EBS 的 容量 或 多 volume
然後自訂成 AMI , 也可以修訂此 EBS 的 容量 或 多 volume
然後再去 Lanch Instance --> My AMIs --> 選擇剛剛自己定義的 AMIs
PS 如果成本考量 , 要記得去刪除 AMI images > <" ~
2016年2月25日 星期四
[SSL] - Ubuntu 14.x Let's Encrypt's + Nginx
使用 Let's Encrypt's 來驗證
# sudo apt-get update
# sudo apt-get install git apt-get update
# apt-get install git bc
# service nginx stop
# git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# cd /opt/letsencrypt
# ./letsencrypt-auto certonly --standalone
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/xlinux.website/fullchain.pem. Your cert will
expire on 2016-05-24. To obtain a new version of the certificate in
the future, simply run Let's Encrypt again.
- If you like Let's Encrypt, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
# vim /etc/nginx/sites-available/default
# 把 80 port 都倒入到 https 443 port
# HTTP 狀態 301/302 說明
# 301: 要求的網頁已經永久改變網址。此狀態要求用戶端未來在連結此網址時應該導向至指定的 URI。
# 302: 物件已移動,並告知移動過去的網址。針對表單架構驗證,這通常表示為「物件已移動」。
# 要求的資源暫時存於不同的 URI 底下。由於重新導向可能偶而改變,
# 用戶端應繼續使用要求 URI 來執行未來的要求。
# 除非以 Cache-Control 或 Expires 標頭欄位表示,
# 此回應才能夠快取。
server {
listen 80;
server_name xlinux.website;
return 301 https://$host$request_uri;
# rewrite ^ https://xlinux.webiste$request_uri? permanent;
}
# 把前面兩行註解掉
server {
#listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
listen 443 ssl;
server_name xlinux.website www.xlinux.website;
ssl_certificate /etc/letsencrypt/live/xlinux.website/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xlinux.website/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';bc
改好後檢查一下設定檔是否 OK
# nginx -c /etc/nginx/nginx.conf -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# 啟動 Nginx
# server nginx start
# vim /etc/nginx/sites-enabled/default
新增 location ~ /.well-known { allow all; }
# cd /opt/letsencrypt/
# ./letsencrypt-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=/var/www/html -d linux.xxxx -d www.xlinux.xxx Checking for new version... Requesting root privileges to run letsencrypt... /home/ubuntu/.local/share/letsencrypt/bin/letsencrypt --no-self-upgrade certonly -a webroot --agree-twww/html -d www.xlinux.xxxx -d www.xlinux.xxxx IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/www.xlinux.website/fullchain.pem. Your cert will expire on 2016-05-26. To obtain a new version of the certificate in the future, simply run Let's Encrypt again. - If you like Let's Encrypt, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
到 Qualys SSL 驗證 https://www.ssllabs.com/
This server supports weak Diffie-Hellman (DH) key exchange parameters. Grade capped to B.
# sudo apt-get update
# sudo apt-get install git apt-get update
# apt-get install git bc
# service nginx stop
# git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# cd /opt/letsencrypt
# ./letsencrypt-auto certonly --standalone
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/xlinux.website/fullchain.pem. Your cert will
expire on 2016-05-24. To obtain a new version of the certificate in
the future, simply run Let's Encrypt again.
- If you like Let's Encrypt, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
# vim /etc/nginx/sites-available/default
# 把 80 port 都倒入到 https 443 port
# HTTP 狀態 301/302 說明
# 301: 要求的網頁已經永久改變網址。此狀態要求用戶端未來在連結此網址時應該導向至指定的 URI。
# 302: 物件已移動,並告知移動過去的網址。針對表單架構驗證,這通常表示為「物件已移動」。
# 要求的資源暫時存於不同的 URI 底下。由於重新導向可能偶而改變,
# 用戶端應繼續使用要求 URI 來執行未來的要求。
# 除非以 Cache-Control 或 Expires 標頭欄位表示,
# 此回應才能夠快取。
server {
listen 80;
server_name xlinux.website;
return 301 https://$host$request_uri;
# rewrite ^ https://xlinux.webiste$request_uri? permanent;
}
# 把前面兩行註解掉
server {
#listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
listen 443 ssl;
server_name xlinux.website www.xlinux.website;
ssl_certificate /etc/letsencrypt/live/xlinux.website/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xlinux.website/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';bc
改好後檢查一下設定檔是否 OK
# nginx -c /etc/nginx/nginx.conf -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# 啟動 Nginx
# server nginx start
# vim /etc/nginx/sites-enabled/default
新增 location ~ /.well-known { allow all; }
# cd /opt/letsencrypt/
# ./letsencrypt-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=/var/www/html -d linux.xxxx -d www.xlinux.xxx Checking for new version... Requesting root privileges to run letsencrypt... /home/ubuntu/.local/share/letsencrypt/bin/letsencrypt --no-self-upgrade certonly -a webroot --agree-twww/html -d www.xlinux.xxxx -d www.xlinux.xxxx IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/www.xlinux.website/fullchain.pem. Your cert will expire on 2016-05-26. To obtain a new version of the certificate in the future, simply run Let's Encrypt again. - If you like Let's Encrypt, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
service nginx reload
bulid script
# cp /opt/letsencrypt/examples/cli.ini /etc/letsencrypt/live/renew.ini
# vim /etc/letsencrypt/live/renew.ini
rsa-key-size = 4096
email = fifixxxxxx@gmail.com
domains = xlinux.xxxx, www.xlinux.xxxx
webroot-path = /var/www/html
# /opt/letsencrypt/letsencrypt-auto certonly -a webroot --renew-by-default --config /etc/letsencrypt/live/renew.ini
# 撰寫 Cront 自動更新
30 2 * * 1 /xxxxxxxxx >> /var/log/renewal.log
到 Qualys SSL 驗證 https://www.ssllabs.com/
This server supports weak Diffie-Hellman (DH) key exchange parameters. Grade capped to B.
Weak Diffie-Hellman 問題,Diffie-Hellman 預設長度不夠
使用 openssl 產生 4096 bit tell nginx to use it for DHE key-exchange:
# cd /etc/ssl/certs
# openssl dhparam -out dhparam.pem 4096 ( 這個會跑很久 , 在 AWS haw SSD 上跑要十五分鐘 ...... )
# vim /etc/nginx/sites-enabled/default
server {
#listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
listen 443 ssl;
server_name xlinux.website www.xlinux.xxxx;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_certificate /etc/letsencrypt/live/xlinux.xxxx/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xlinux.xxxx/privkey.pem;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
#ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
add_header Strict-Transport-Security max-age=31536000;
2016年2月24日 星期三
[AWS] - Support Center
忘記大概何時啟用 Usage Free Tier , 後台也查不到時間
只好寫信去詢問 Supoort Center , ( 鼎新也有類似的 eService 可以使用 , 跟主題無關 > <" )
只好寫信去詢問 Supoort Center , ( 鼎新也有類似的 eService 可以使用 , 跟主題無關 > <" )
AWS Support 還有分等級回覆 , 好的服務當然要收費 ~
- PS 突然想到註冊的時候都會有發信件到註冊 Email , 但 ~~ 就順便測試一下 AWS Support 的威力 :D
檢察了信件 , 於 2016/02/25 PM 11:06回信
回信速度大概九個小時左右
2016年2月23日 星期二
[AWS] - Windows Instance Build
- AWS 後台建立一個新的 Instances ,
- 選擇 AWS Markplace 的 AMI 來建立 ( 官方版的比較不會亂來 > <" )
Type 要選 HVM ( 透過 CPU VT技術資源 ) 比較好的樣子
PS ( PVM的是用軟體模擬 ex. Xen )
建立後使用 Elastic IPs Allocate New Address
- Security Gruops 新增 RDP
- 選擇所做的 key pairs *.pem , 來 decode 出密碼
- 打開 Windows RDP Clinet 輸入 Public IP & 解譯後密碼
進去Windows 後 再修改 Administrator 的密碼即可PS ( Windows 版權好像包含在 AMI 建立後的 Instance 有收費依據
http://aws.amazon.com/tw/ec2/faqs/#When_I_import_a_VM_of_Windows_Server_2003_or_2008,_who_is_responsible_for_supplying_the_operating_system_license
)
- Billing 那邊也會有顯示使用的報表
[AWS] - Billing
昨天把 Instance 關掉 , 今天帳單上面多了
是 OK的 > <" ( 24 x 6天 ) x 2 台 = 288
- Elastic IPs 沒有綁到 Instance 也會扣款 > <" 8hr / $0.04 US
- 使用 Route53 代管一筆 Domain ,1 HostedZone $0.50 US , 70Queries 目前 $0.01 US
- EC2 目前這個月的 free tier t2.micro ( 750 ) 用了 484 剩下 266
是 OK的 > <" ( 24 x 6天 ) x 2 台 = 288
- Free - Tier 到期後如果要繼續使用 t2.micro 微型的話可到這邊來計算,目前所使用的各項 AWS 正常收費是多少 http://calculator.s3.
amazonaws.com/calc5.html?key= my-free-website
= 2833.4592 TWD
2016年2月22日 星期一
[AWS] - EC2 + RDS
- 1. 選擇要用的資料庫
A. MYSQL 已經可以使用 5.7 的版本,
B. Amazon 自己的極光 Aurora
High performance MySQL-compatible, enterprise-class database at 1/10th the cost of
commercial databases
C .先選擇使用 MariaDB 來做測試驗證
- 2. 選定要開發用的 Dev 而不是產品要用的 ,
- 3. 選定所需要的硬體資源資訊 , Multi-AZ 要選NO , 除非後續公司有必要使用
- 4. 從 EC2 instance 測試驗證連接
root@ip-172-31-20-24:/var/www/html/pma# mysql -u root -p -h 172.xx.xx.xx
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.0.17-MariaDB-log MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> quit
Bye
- 5. 好像可以直接 Replication 不知道有沒有類似 node 的概念來做 MMM
ex. mariadb galera cluster
- 6. 還可以選 Destination Region , 台灣的話就選 東京 或 新加坡
2016年2月21日 星期日
[AWS] - Route53 + EC2 LEMP ( Ubuntu14 + Nginx + PHP5 + MariaDB )
去 Godaddy 逛逛看到了一組 39 元 TWD 網域註冊後 ,
5. 到 Elastic IP (EIP) 綁定固定 IP , 不然 Instance Reboot 都會換 IP
當測試來驗證一下 AWS 的 EC2 + Route53
3. 到 AWS Route53 設定一組 IPV4 的 A 紀錄
Ex. fifi.xlinux.website xxxxxxxxxxxx
PS ( 大概等了 1個小時以內就生效 )
4. AMI(Amazon Machine Image) 打開 AMI 建立一個 Instance , 選擇 Ubuntu14
5. 到 Elastic IP (EIP) 綁定固定 IP , 不然 Instance Reboot 都會換 IP
6. 設定 SSH 連線
A. 先建立一組 Key Pairs xxx.pem
使用 pietty or putty or xshell ..etc 來連線
匯入 xxx.pem 或透過 Linux console
ssh -i 'xx.pem' ubuntu@fifi.xlinux.website
B. 若要取消 key Pairs , 編輯 sshd config
# vim /etc/ssh/sshd_config
PasswordAuthentication YES
C. 重新啟動 sshd
# service sshd restart
7. 到 Security Group 設定防火牆存取
打開 icmp 跟 web 的 port
8. 安裝 LEMP
A. 安裝 MariaDB
# apt-get install mariadb-server
B. 安裝 Web Nginx
# apt-get install nginx
C. 安裝 PHP FPM
# apt-get install php5-fpm php5-mysql
D. 設定 PHP FPM 9000 port 啟動
# vim /etc/php5/fpm/pool.d/www.conf
; listen = /var/run/php5-fpm.sock
listen = 127.0.0.1:9000
# service php5-fpm restart
E. 設定 Nginx 透過 php fpm 運作 script
# vim /etc/nginx/sites-enabled/default
root /var/www/html;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# service nginx restart
訂閱:
文章 (Atom)