Tuhinga Tuhinga
Me pehea te tono mo Let's Encrypt?
Kia Whakamuna te Tikanga Tiwhikete SSL me te Akoranga Whakataunga
He aha te SSL? I kōrero a Chen Weiliang mō tēnei i roto i tana tuhinga o mua, " He aha te rerekētanga i waenga i te HTTP me te HTTPS? He whakamārama taipitopito mō te tukanga whakamunatanga SSL ."
Haunga ngā paetukutuku hokohoko ipurangi , me hoko e rātou ngā tiwhikete SSL kua whakamunahia matatau, ka taea e ngā tohunga pāpāho hou e whakamahi ana i ngā paetukutuku hei whakatairanga i ā rātou pūkete WeChat te tāuta i ngā tiwhikete SSL kua whakamunahia kore utu. Ka taea e tēnei te āwhina i te SEO me te whakapai ake i te tūnga kupumatua o te paetukutuku i roto i ngā miihini rapu.

He tukanga mahi anō tā Let's Encrypt ( https://certbot.eff.org/ ). Ka taea e ngā kaiwhakamahi Linux te tirotiro i taua tukanga mahi me te whai i tēnei akoranga.
Tangohia te taputapu certbot-auto i te tuatahi, katahi ka whakahaere i nga whakawhirinakitanga whakaurunga o te taputapu.
wget https://dl.eff.org/certbot-auto --no-check-certificate chmod +x ./certbot-auto ./certbot-auto -n
Hanga tiwhikete SSL
Muri iho, hei tauira, me whakarerekē te ingoa rohe o te rangitaki a Chen Weiliang kia rite ki ō hiahia, kātahi ka whakahaere i te whakahau e whai ake nei mā te SSH.
Kia mahara ki te whakarereke i te tono:
- Pouakaeta
- ara tūmau
- ingoa rohe paetukutuku
Takitaki rohe kotahi, whakaputa tiwhikete:
./certbot-auto certonly --email [email protected] --agree-tos --no-eff-email --webroot -w /home/admin/web/chenweiliang.com/public_html -d www.chenweiliang.com
Whaiaronga rohe-maha kotahi, hangaia he tiwhikete: (ara, ingoa rohe maha, whaiaronga kotahi, whakamahia te tiwhikete kotahi)
./certbot-auto certonly --email [email protected] --agree-tos --no-eff-email --webroot -w /home/admin/web/chenweiliang.com/public_html -d www.chenweiliang.com -d img.chenweiliang.com
Ka tiakina te tiwhikete SSL i hangaia ki:/etc/letsencrypt/live/www.chenweiliang.com/ I raro i nga korero.
He maha nga ingoa rohe me nga raarangi maha, hangaia he tiwhikete: (ara, ingoa rohe maha, raarangi maha, whakamahia te tiwhikete kotahi)
./certbot-auto certonly --email [email protected] --agree-tos --no-eff-email --webroot -w /home/admin/web/chenweiliang.com/public_html -d www.chenweiliang.com -d img.chenweiliang.com -w /home/eloha/public_html/site/etufo.org -d www.etufo.org -d img.etufo.org
I muri i te whakaurunga pai o te Tiwhikete Whakamuna Tatou, ka puta te karere tere e whai ake nei ki SSH:
NGĀ WHAKAMAHI MANA'O:
– Kia ora to tiwhikete me te chain kua tiakina ki:
/etc/letsencrypt/live/www.chenweiliang.com/fullchain.pem
Kua tiakina to kōnae matua ki:
/etc/letsencrypt/live/www.chenweiliang.com/privkey.pem
Ka pau to tiwhikete a te 2018-02-26. Ki te whiwhi i tetahi mea hou, kua takawiri ranei
putanga o tenei tiwhikete a meake nei, whakahaere noa certbot-auto
Ki te whakahou kore-tauwhitiwhiti *katoa* o o tiwhikete, rere
"certbot-aunoa whakahou"
- Mena he pai ki a koe a Certbot, me whakaaro ki te tautoko i a maatau mahi ma:
Te koha ki a ISRG / Let's Encrypt: https://letsencrypt.org/donate
Te koha ki a EFF: https://eff.org/donate-le
Whakahoutanga Tiwhikete SSL
He tino watea hoki te whakahou tiwhikete, mā te whakamahi i te crontab hei whakahou aunoa. Mō ētahi putanga Debian kāore anō kia tāutahia te crontab, ka taea e koe te tāuta ā-ringa i te tuatahi.
apt-get install cron
Ko ngā whakahau e whai ake nei mō te nginx me te apache ka tāuruhia ki te kōnae /etc/crontab , ko te tikanga ka whakahoutia i ia 10 rā, ā, he rawaka te wā mana 90-rā.
Nginx crontab kōnae, tēnā tāpirihia:
0 3 */10 * * /root/certbot-auto renew --renew-hook "/etc/init.d/nginx reload"
Kōnae Apache crontab, tāpirihia koa:
0 3 */10 * * /root/certbot-auto renew --renew-hook "service httpd restart"
Tiwhikete SSL whirihoranga Apache
Inaianei, me whakarereke tatou ki te whirihoranga Apache.
Tips:
- ki te whakamahi koePaewhiri Mana CWP, i roto i te Tāpiri ingoa rohe taki Whakaputa aunoa i te tiwhikete SSL, ka whirihora aunoa i te tiwhikete SSL mo Apache.
- Mena ka mahia e koe etahi atu waahanga e whai ake nei, ka puta he hapa i muri i te whakaara ano i a Apache.
- Mena he hapa, mukua te whirihoranga i tapiritia e koe ma te ringa.
Whakatikaina te kōnae httpd.conf ▼
/usr/local/apache/conf/httpd.conf
Kimihia ▼
Listen 443
- (tangohia te nama korero o mua #)
tāpirihia rānei te tauranga whakarongo 443 ▼
Listen 443
SSH tirohia te tauranga whakarongo a Apache ▼
grep ^Listen /usr/local/apache/conf/httpd.conf
Kimihia ▼
mod_ssl
- (tangohia te nama korero o mua #)
tāpiri ranei ▼
LoadModule ssl_module modules/mod_ssl.so
Kimihia ▼
httpd-ssl
- (tangohia te nama korero o mua #)
Na, mahia e te SSH te whakahau e whai ake nei (tohu kia huri te ara ki a koe ake):
at >/usr/local/apache/conf/extra/httpd-ssl.conf<<EOF Listen 443 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLProxyCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLHonorCipherOrder on SSLProtocol all -SSLv2 -SSLv3 SSLProxyProtocol all -SSLv2 -SSLv3 SSLPassPhraseDialog builtin SSLSessionCache "shmcb:/usr/local/apache/logs/ssl_scache(512000)" SSLSessionCacheTimeout 300 SSLMutex "file:/usr/local/apache/logs/ssl_mutex" EOF
Muri iho, i te mutunga o te whirihoranga Apache mō te paetukutuku i hangaia e koe, i raro i te </VirtualHost>.
Taapirihia te konae whirihoranga o te waahanga SSL (tohua hei tango i te korero, ka huri i te huarahi ki a koe ake):
<VirtualHost *:443> DocumentRoot /home/admin/web/chenweiliang.com/public_html //网站目录 ServerName www.chenweiliang.com:443 //域名 ServerAdmin [email protected] //邮箱 ErrorLog "/var/log/www.chenweiliang.com-error_log" //错误日志 CustomLog "/var/log/www.chenweiliang.com-access_log" common //访问日志 SSLEngine on SSLCertificateFile /etc/letsencrypt/live/www.chenweiliang.com/fullchain.pem //之前生成的证书 SSLCertificateKeyFile /etc/letsencrypt/live/www.chenweiliang.com/privkey.pem //之前生成的密钥 <Directory "/home/admin/web/chenweiliang.com/public_html"> //网站目录 SetOutputFilter DEFLATE Options FollowSymLinks AllowOverride All suPHP_UserGroup eloha eloha //用户组(有些服务器配置需要,有些可能不需要,出错请删除此行) Order allow,deny Allow from all DirectoryIndex index.html index.phps </Directory> </VirtualHost>
Ka mutu ka whakaara ano a Apache ki runga:
service httpd restart
Ka kaha a Apache ki te whakawhiti HTTP ki HTTPS
- He maha nga tono tukutuku ka taea anake te whakahaere me te SSL.
- Me mohio tatou i nga wa katoa ka whakamahi tatou i te SSL, me uru te paetukutuku ma te SSL.
- Mena ka ngana tetahi kaiwhakamahi ki te uru atu ki te paetukutuku me te URL kore-SSL, me tukuna atu ia ki te paetukutuku SSL.
- Tukuna ki SSL URL ma te whakamahi i te Apache mod_rewrite module.
- Mēnā ka whakamahi koe i te mōkihi tāutanga paato-kotahi o te LAMP, te whakaurunga aunoa o te tiwhikete SSL me te huri ano ki te HTTPS, te hurihanga ki te HTTPS.Kei te kaha, kaore koe e hiahia ki te taapiri i te HTTPS anga whakamua.
Tāpiri ture anga whakamua
- I roto i te konae whirihoranga a Apache, whakatikahia te kaihautu mariko o te paetukutuku me te taapiri i nga tautuhinga e whai ake nei.
- Ka taea hoki e koe te taapiri i nga tautuhinga rite ki te pakiaka tuhinga i to paetukutuku i roto i to konae .htaccess.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]Mena kei te hiahia koe ki te tautuhi i tetahi URL hei tuku ki te HTTPS:
RewriteEngine On RewriteRule ^message$ https://www.etufo.org/message [R=301,L]
- Mena ka ngana tetahi ki te uru karere , ka peke te wharangi ki https, ka taea e te kaiwhakamahi te uru ki te URL me SSL anake.
Tīmataria anō a Apache kia whai mana te kōnae .htaccess:
service httpd restart
Nga Whakatakarotanga
- Tena koa hurihia te wahitau imeera i runga ake nei ki to wahitau imeera.
- Kia mahara ki te huri i te ingoa rohe paetukutuku i runga ake nei ki to ingoa rohe paetukutuku.
Anō te raruraru tauwāhi ture
Ina whakatakotohia ngā ture tukunga i raro i ngā ture rūpahu-pūmau, ka tūtaki pea koe ki te raruraru kāore e taea e HTTP te tukunga i te pae katoa ki HTTPS.
I te tuatahi i kapea e matou te waehere anga ki .htaccess ka puta mai i nga keehi e whai ake nei ▼
![Kei runga ake te ture whakawhiti [L]. Kei runga ake te ture whakawhiti [L].](https://img.chenweiliang.com/2018/03/https-rule-1.png)
- E tohu ana [L] ko te ture o naianei te ture whakamutunga, kati te tātari i nga ture tuhi ano e whai ake nei.
- No reira ka uru atu koe ki te wharangi tuhinga kua tukuna ano, ka whakamutua e [L] te ture e whai ake nei, no reira karekau te ture anga atu e mahi.
Ina uru atu ki tētahi whārangi kāinga HTTP, me whakaoho he tukunga URL, me te karo i ngā ture tuhi anō URL hei whakahaere i ngā ture tukunga, kia taea ai te tukunga i te pae katoa mai i HTTP ki HTTPS.
Kaua e whakanohohia ngā ture tukunga HTTPS ki raro i ngā ture [L] ; whakanohohia ki runga ake i ngā ture [L] . ▼
![Kei raro nei ngā ture whakawhiti SSL rūpahu-pūmau [L]. Kei raro nei ngā ture whakawhiti SSL rūpahu-pūmau [L].](https://img.chenweiliang.com/2018/03/pseudo-static-ssl-jump.png)
Pānuitanga roa:
- He aha te rereketanga i waenga i te http me te https? He whakamaramatanga mo te tukanga whakamunatanga SSL
- Me aha ahau ki te whiwhi ahau i te hapa 500 i muri i te whakauru i te Tiwhikete Whakamuna SSL i roto i te paewhiri mana CWP?
- Peke aunoa ki te ingoa rohe taumata tuarua kaore he www te ingoa rohe taumata-runga: ka anga te ingoa rohe pakiaka 301 www
Ko te tumanako, ka whai hua ki a koe te tuhinga "Me pēhea te tono mō te Let's Encrypt? Ngā Mātāpono me te Akoranga Tāutanga o ngā Tiwhikete SSL Koreutu a Let's Encrypt" i tohaina ki te blog a Chen Weiliang ( https://www.chenweiliang.com/ ).
Tukuna mai te hononga o tēnei tuhinga: https://www.chenweiliang.com/cwl-512.html
