分類
网站

網站用上了letsencrypt的免費ssl證書

使用 certbot 獲取證書

請訪問 certbot instructions 安裝 cerbot。在 CentOS 7 和 8 中使用 certbot 搭配 Cloudflare 插件實現自動更新證書的安裝與配置流程是這樣的:

#安裝 snapd 參考:https://snapcraft.io/docs/installing-snap-on-centos
sudo yum install epel-release
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install core
sudo snap refresh core

#刪除舊版 certbot
sudo yum remove certbot
#安裝 certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo snap set certbot trust-plugin-with-root=ok
#安裝 Cloudflare 插件
sudo snap install certbot-dns-cloudflare
#配置 Cloudflare api token
nano .cloudflare.ini
#配置文件內容爲

# Cloudflare API token used by Certbot
dns_cloudflare_api_token = QYuhPLUGSPvN30Yry0CXe3PSYJlkIjc_laJgUifd

#修改配置文件權限
chmod 600 .cloudflare.ini

#申請證書
sudo certbot certonly \
  --dns-cloudflare \
  --dns-cloudflare-credentials ~/.cloudflare.ini \
  --dns-cloudflare-propagation-seconds 60 \
  -d ft.shaman.eu.org\
  -d plausible.manchuria.eu.org

#測試自動更新
sudo certbot renew --dry-run --dns-cloudflare --dns-cloudflare-credentials ~/.cloudflare.ini --dns-cloudflare-propagation-seconds 60
# crontab 自動更新配置
52 2 * * 0 certbot renew --dns-cloudflare --dns-cloudflare-credentials /home/42/.cloudflare.ini --dns-cloudflare-propagation-seconds 60 --post-hook "nginx -s reload"

#查看當前已經申請的證書
sudo certbot certificates 

通過 DNS-01 challenge 方式獲取證書

由於有台服務器未打開 80 端口且用了 Cloudflare 的 CDN,所以採用 DNS 的方式來獲取證書。>

sudo certbot certonly --manual --preferred-challenges=dns -d ft.wupo.info
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.ft.wupo.info with the following value:

7G6Qad5U7z4u4036tk1e5DAPGZ2WSbaSDFhlYLBnjcQ

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
#此時去 Cloudflare 的 DNS 記錄中新增一條 TXT 類型,名稱是 _acme-challenge.ft,內容為 
# 7G6Qad5U7z4u4036tk1e5DAPGZ2WSbaSDFhlYLBnjcQ 
# 的記錄,保存後稍微等待一下下待 DNS 生效,然後回來繼續
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/ft.wupo.info/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/ft.wupo.info/privkey.pem

不使用 snap

有台 CentOS 8 安裝 snap 不成功,使用 pip 來申請 Let’s Encrypt 證書也是很方便的。

首先在 nginx 配置一個空網站,如

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    server_name ft.shaman.eu.org;
}

然後:



sudo dnf install python3 augeas-libs
sudo dnf remove certbot
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-nginx
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot

#生成證書並自動配置 nginx
sudo certbot --nginx
#或僅生成證書
sudo certbot certonly --nginx


小撇步

雖然已經 2024 年底,但是客戶的 CentOS 7 還在運行。安裝的時候不要使用系統自帶的 python3.6,太舊啦。最好自己編譯一個新版 python3 。降級 urllib3 sudo /opt/certbot/bin/pip install urllib3==1.26.7 可以避免 ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+

--以下爲久遠內容不足爲看--

藉助於SSL For Free,可以快速申請Let's Encrypt的SSL證書,然後複製到Vesta Panel中就OK啦,非常方便。實在太簡單啦,所以沒什麼可寫的。證書有效期三個月,快過期時可再次免費更新。

nginx中將http重定向到https,可以在配置文件中這樣設置:

server {
    listen      80;   #listen for all the HTTP requests
    server_name example.com www.example.com;
    return      301         https://www.example.com$request_uri;
}

SSL For Free的證書直接用在nginx上

Certificate Successfully Generated後,下載生成的證書,合併certificate.crt和ca_bundle.crt

cat certificate.crt >> bundle.crt
printf "\n" >> bundle.crt
cat ca_bundle.crt >> bundle.crt

nginx的配置可以這樣寫

server {
    listen 192.111.111.111:443 ssl;
    server_name ft.wupo.info;

    ssl_certificate     /etc/letsencrypt/42/bundle.crt;
    ssl_certificate_key /etc/letsencrypt/42/private.key;
    ssl_protocols	TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

本文更新於 2024/11/29。

分類
网站

Mobile Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

分類
方法

開啟谷歌位置記錄

谷歌的位置記錄是種後台服務,默默的為你記下你所去過的地方。我去香港台灣韓國泰國的都有記錄,但是一回祖國就自動關閉無法開啟了。以前也沒太在意,但是上次去泰國,發現谷歌NOW還是挺有意思的,還有回來後玩谷歌Fit,也是需要開啟位置記錄才能玩的爽。於是搜了開啟谷歌位置記錄的方法,效果是可以開啟谷歌位置記錄,缺點是位置是偏的。

我這邊環境是:sony z已root,已安裝Xposed和Xprivacy,影梭按應用代理所有谷歌服務。首先打開Xprivacy,菜單/篩選,勾選顯示系統app。搜索google,找到Google Play 服務,在我這裡Google Play服務是和Google Backup Transport,Google帳號管理員等在一個條目里的。點擊進入後找到"手機資訊(SIM卡)"菜單,點開摺疊按鈕,勾選上如下條目:

  • getNetworkCountryIso
  • getNetworkOperator
  • getNetworkOperatorName
  • getSimCountryIso
  • getSimOperator
  • getSimOperatorName
選上後,點擊菜單/設定,修改MCC為466,MNC為92,國家為TW,電信商為Chunghwa,勾選國家前的選框。最後點右上角保存即可。然後回位置記錄就看到可以開啟了。

後記:當我回來Xprivacy看設置的時候,發現國家那一欄變成了XX,不知到為什麼。參考資料:https://plus.google.com/+liufc/posts/9LE3NHY8LGE。

分類
网站

CSS tricks

關於響應式設計@media的基礎只是可以參考CSS3 Media Queries 詳細介紹與使用方法,我剛剛的需求是,手機端覆蓋正常的部分CSS代碼,只需這樣寫就好:

@media screen and (max-width: 767px) {
/* Common borders. */
.page-header,
.comment-list,
.author-info,
.comment-navigation,
.post-navigation,
.hentry:not(:last-child) {
  margin: 0 0 0 0em;
  padding: 0 0 0 0em;
  border-bottom: none;
} 

頁面底部浮動按鈕

<!--html-->
<div style="position: fixed; left: 50%; margin-left: -77px; bottom: 80px; width: 154px; box-sizing: border-box; text-align: center;">
    <div style="padding:10px 0; text-align:center;">  
        <span onclick="fbs_click1()" style="width:44px;height:20px;padding:0px;border-radius:20px;display:block;color:#fff;line-height:30px;z-index:1000; text-align:center;float:left;margin-right:15px;">
            <img src="facebook_share.png" style="width:44px;height:20px;"/>
        </span>
        <span onclick="shareToLine42()" style="width:40px;height:40px;background-color:#6db533;padding:0px;border-radius:20px;display:block;color:#fff;line-height:40px;z-index:1000; text-align:center;float:left;margin-right:15px;">
            LINE
        </span>    
        <span style="width:40px;height:20px;padding:0px;border-radius:20px;display:block;color:#fff;line-height:30px;z-index:1000; text-align:center;float:left;">
            <div class="fb-like" data-action="like" data-layout="button" data-href="https://www.facebook.com/yourPage/"></div>
        </span>   
    </div>
</div>
<!--js-->
<script>
function fbs_click1() { u = "http://yourdomin.com/yourpage"; t = document.title; window.open('https://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=600'); return false; };
function shareToLine42(){
  lineUrl="http://line.me/R/msg/text/?<?php the_title(); ?>%0D%0A<?php the_permalink(); ?>";
  window.open(lineUrl, 'sharer', 'toolbar=0,status=0,width=626,height=436');
}
</script>
<!--若要強制facebook彈出窗口的寬度,需添加css-->
<style>
.fb_iframe_widget>span { width: 309px !important; }
.fb-like-box iframe { width: 309px !important; }
</style>

css虛化圖片做背景:參考這兩個http://codepen.io/akademy/pen/FlkzBhttp://codepen.io/aniketpant/pen/DsEve

本文更新於 2016/06/29。

分類
网站

wordpress站點多域名

首先DNS要指向wordpress所在IP,然後配置虛擬主機,我是複製了一份conf,修改server_name為新增加的域名如blog.newdomin.com,其他不變。然後重啟nginx就可以用兩個域名訪問同一個網站了。

如果想把鏈接中的域名也換了,則需要在wp-config.php中增加兩行:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
分類
音乐

Bad Taste But I Smell Good Lyric

【 Bad Taste[But I Smell Good](呷好道相報) 】【 粵語 】【 2002-01 】

1.黑白亂講
2.I Don't Wanna Grow Up
3.偶然
4.男人四十無得撈
5.Blowin' In The Wind
6.幸福摩天輪
7.大佬
8.海闊天空
9.尖沙咀Tommy
10.活在當下
11.All Apologies
12.將進酒
13.尖沙咀(Hidden Track)



1.黑白亂講

瘋言瘋語 花言巧語 胡言亂語
黑白亂講 你到底有聽到 沒有你哪聽到怎不去做(閩南語)*4

潮起潮落不變 是是非非難辯(國語)

Rap:(廣東話)
個世界有幾大問你究竟曉唔曉呀
老爺吩咐落要叻過上海班老表
你條*樣有幾多料大家心*照我話你
真識講笑係講出黎比人笑

Oh…China boy,China boy, China boy

黑白亂講 你到底有聽到 沒有你哪聽到怎不去做(閩南語)*4

潮起潮落不變 是是非非難辯(國語)

Rap:(廣東話)又話搵出路直得係搵出個搏大霧得個講又唔識做
但係個個又無野做你話要增值聽你講我就真係訓直你話要托市
不如買個罩托返起你個度Oh…don't cry for me , next door neighbour

黑白亂講 你到底有聽到 沒有你哪聽到怎不去做(閩南語)




2.I Don't Wanna Grow Up

Well 求求其其話我愛你 I don't wanna grow up
糊糊地碰普你 I don't wanna grow up
一生悲慘有著你 青春俾曬你
天天爭吵也為你 死啦!

喂麻麻煩煩仲要愛你 I don't wanna grow up
完完全全地怕了你 I don't wanna grow up

真的不忍看著你 豬母好過你
心中天天咒者你 死啦!

咿咿哦哦仲要鍚你 I don't wanna grow up
無無聊聊又要霎氣 I don't wanna grow up

辛辛苦苦要受氣 真的好谷氣啦喂
點解身邊會係你 點解天主要做你
點解巴士有撞你 點解青山要放你
I don't wanna grow up well

完全誠實就算愛你 I don't wanna grow up
時時提住話我愛你 I don't wanna grow up
早知當初有去六四 點解偏偏我碰上你
今天好想有了你鬆啦喂

Woo為何神話愛最美 I don't wanna grow up
原來神話佢騙你 I don't wanna grow up

點解家陣有曬氣 點解吵親佢有理
點解收工也反受氣 點解飲酒要問你
點解也都我就你 點解屎坑要我理
點解分手有勇氣 I don't wanna grow up




3.偶然

作詞:徐志摩
作曲:陳秋霞
原唱:陳秋霞

我是天空裡的一片雲
偶爾投影在你的波心
你不必訝異 無須歡喜
在轉瞬間消滅了蹤影

*你我相逢在黑夜的海上
 你有你的 我有我的方向
 你記得也好
 最好你忘掉
 在這交會時互放的光亮

Repeat *




4.男人四十無得撈

作詞:黃秋生
作曲:黃秋生

好驚也野都無 又怕會無曬前途
身體開始衰老 最怕會無得撈
香港經濟仆到 仲快過剃你條毛
金行都閂鋪 老細要走佬 窮到被竇都無

講開都會激到 凸曬眼發曬勞嘈
執笠多過開舖 仲要你信會好好
比班仆街搞到 賣當借湊夠6毫
終於乜都無 嗌句老撚土望阿伯你收到

最怕你個貓樣死樣 每次見佢講野無到 令我嘔吐
個市跌到雞飛狗走 你卻叫我等下訓下如何是好
山頂跳樓好 實會似股市 夠曬恐佈

當初楂幾間鋪 仲有發奮既路途
家陣爭一身數 嚇到腳軟甩毛
終於開始知道 沒法再信個盲毛
講開一匹布 當我無彩數 撞正你我反肚




5.Blowin' In The Wind

How many roads most a man walk down Before you call him a man?
How many seas must a white dove sail
Before she sleeps in the sand? Yes, how many times must the cannon balls fly
Before they're forever banned?
The answer my friend is blowing in the wind The answer is blowing in the wind.
Yes, how many years can a mountain exist
Before it's washed to the sea? Yes, how many years can some people exist
Before they're allowed to be free?
Yes, how many times can a man turn his head pretending he just doesn't see?
The answer my friend is blowing in the wind
The answer is blowing; in the wind.Yes, how many times must a man look up
Before he can see the sky?
Yes, how many ears must one man have Before he can hear people cry?
Yes, how many deaths will it take till he knows
That too many people have died? The answer my friend is blowing in the wind
Theanswer is blowing in the wind.




6.幸福摩天輪

作詞:林夕
作曲:Eric Kwok
編曲:劉祖德

追追趕趕 高高低低
深呼吸然後與你執手相隨
甜蜜中不再畏高
可這樣跟你蕩來蕩去 無畏無懼

* 天荒地老流連在摩天輪
在高處凝望世界流動
失落之處仍然會笑著哭
人間的跌盪 默默迎送
當生命似流連在摩天輪
幸福處隨時吻到星空
驚慄之處仍能與你互擁
彷彿遊戲之中 忘掉輕重 *

追追趕趕 高高低低
驚險的程度叫畏高者昏迷
憑甚麼不怕跌低
多僥倖跟你共同面對 時間流逝

東歪西倒 忽高忽低
心驚與膽戰去建立這親厚關係
沿途就算意外脫軌
多得你 陪我搖曳
Repeat * *




7.大佬

作詞:黃秋生
作曲:黃秋生

我係你大佬 大佬就照顧你老母
佢係你二嫂 義氣就佢話也都好
劈鑊你又好 又打又踢也要嗌好
你話咁易撈 在世上邊處氳得到

我係你大佬 大佬就教訓個細佬
你話要食草 仲借住五舊去亂薄
去做鴨又好 食草又點及訓覺好
我地拍住撈 就冇話一個桔都有

有日你大佬 要得滯要去進下補
你就有排撈 話過實顧住你前途
最閉你二嫂 做乜係要殺你老母
你為你大佬 義氣就乜都可得到

五十個大佬 大x鑊約曬去著草
你地立定刀 食過飯買藥水膠布
買十個大佬 就睇住轉角個當鋪
你若信大佬 上帝實照住你條毛




8.海闊天空

作詞:黃家駒
作曲:黃家駒

今天我 寒夜裡看雪飄過
懷著冷卻了的心窩漂遠方
風雨裏追趕
霧裡分不清影蹤
天空海闊你與我
可會變(誰沒在變)

多少次 迎著冷眼與嘲笑
從沒有放棄過心中的理想
一剎那恍惚
若有所失的感覺
不知不覺已變淡
心裡愛(誰明白我)

原諒我這一生不羈放縱愛自由
也會怕有一天會跌倒
背棄了理想 誰人都可以
那會怕有一天只你共我

仍然自由自我
永遠高唱我歌走遍千里




9.尖沙咀Tommy

作詞:黃秋生
作曲:許冠傑

有佢咁懶時有佢咁會慳 尖沙咀Tommy吹水由餐
日日約Suzie開波當食晏 週身card數都好閒
佢永遠懶懶閒 索野佢最o巖 乜都High一輪火水浸底衫
Fing啊Fing到失魂豬扒佢又讚 High足七晚死都撐

尖沙咀Tommy 搞也都都會彎(終於得隻蛋)
佢老竇誠實慣 係深圳賣老翻
尖沙咀Tommy 熨雞都無膽 貪舒服怕困難 叫佢去執都懶
有佢咁寸時有佢咁細 標準好身形得個5呎3
未做過英雄 衰仔佢做慣 睇多一眼都好難
你有野要買時咪叫佢去班 囉o左Money走去買衫
但望阿Tommy 聽朝咪食晏 死鬼o左佢天開眼




10.活在當下

我看到滿山遍芳草 靜靜地在配合舞步 似聽見有天使飛到在傾訴
細細說會給我禱告 落著淚為那日引路 慢慢幻象示現在側

剎那美色已經變蒼老 活力亦在每日退步 已悄悄再抵抗不了
命途至愛瞬間變沙土 地位亦是旦夕不保 剩下寂靜沉沉全無力

生憂傷忍耐 死轉身已在
想昨日可在 明天可否會來

慨以往怎麼也洗不去 望望現在落寞地抹眼淚 悔過去總感覺空虛問誰
晦暗裡以千金買得癡醉 慢慢地讓潔白亦染滿罪 朦朦朧朧永遠沉沉睡到

這裡冷風已消去 獨自站在雨下悔罪 遠遠的街燈似星光散碎
告訴我要安心快歸家去 莫為剩下歲月掛慮 活著自在常常提醒

生死的所在 死出生已在
想昨日可在 明天可否會來

生憂傷忍耐 死轉身已在
想昨日可在 明天可右會來




11.All Apologies

What else should I be All apologies.
What else should I say Everyone is gay
What else should I write I don't have the right
What else should I be All apologies in the sun in the sun
I feel as one in the sun in the sun
I'm married Buried
I wish Iwas like you easily amused Find my nest of salt
Everything is my fault
I'll take all the blame Aqua seafoam shame
Sunburn with freezer burn choking on the ashes of her enemy
in the sun in the sun I feel as one in the sun in the sun
I'm married Buried Married Buried
All in all is all we all are




12.將進酒

潮來潮去 日落日出 黃河也變成了一條陌生的流水
江山如畫 時光流轉 秦時的明月漢時關

雙手擁抱 是一片國土的沉默 少年的我迷惑
攤開地圖 飛出一條龍 故園回首明月中

風花雪月 自古依然 袓先的青春刻在竹板上
愛情如新 愛情又來 聖賢也擋不住風流的情懷

多愁善感的妳 已離我而去 酒入愁腸成相思淚
驀然回首 想起我倆的從前 一個斷了翅的諾言

光陰似箭 日月如梭 童年的文章如此作
青春不再 往日情懷 我未曾珍惜的我不再擁有

親愛的朋友 你的心事重重 何處是往日的笑容
莫再提起 那人世間的是非 今宵有酒今宵醉

莫再提起 那人世間的是非 今宵有酒今宵醉




13.尖沙咀(Hidden Track)



歌詞轉自魔鏡歌詞網

分類
Linux

VirtualBox中Ubuntu掛載新磁盤[轉]

在virtualbox中装好Ubuntu后,发现硬盘空间太小,怎样才能增加硬盘容量?那就是再建一个硬盘:

1. 添加新硬盘

设置 -> Storage -> SATA控制器->右击,选择“添加虚拟硬盘”

然后,根据需求创建合适的硬盘

2. 重启虚拟机

查看现有系统的磁盘空间

sudo fdisk -l

可看到新加的虚拟硬盘,一般名为:Disk /dev/sdb

3. 给新加的硬盘分区

fdisk /dev/sdb

键入m,可看到帮助信息

command (m for help):m

增加新分区

command (m for help):n

选择基本分区,输入:p

建一个分区

Partition number(1-4):1

回车

First cylinder (1-15908,default 1):Enter

写入并退出

command (m for help):w

4. 格式化磁盘分区

用ext4格式对/dev/sdb1进入格式化

sudo mkfs.ext4 /dev/sdb1

5. 挂载分区

创建新的挂载点

sudo mkdir /work

将新磁盘分区挂载到/work目录下

sudo mount -t ext4 /dev/sdb1 /work

查看挂载

df -h

可以看到新加的硬盘:/dev/sdb1

6. 开机自动挂载

修改文件

sudo nano /etc/fstab

在最后一行加入:

/dev/sdb1 /work ext4 errors=remount-ro 0 1

完成!

文章轉自本文出自 “凉冰” 博客,原文地址http://liangbing8612.blog.51cto.com/2633208/652333