全站再次搬迁到阿里云轻量香港区!
近来在 ping.cat 上看到 LightSail 的 SGP 线路炸得不成样子,访问十分缓慢,这怎么可以呢?!毕竟打开太慢的话就根本不想上来更新了!
思索了半天,遂下手买了阿里云轻量实例香港区一台,按照 METO 聚聚的《服务器安装 ubuntu18.04》一文将自带的 Ubuntu16 重装到了 18.04LTS 版本,部署了 LNMP1.6 的 beta 版本,该版本升级了 PHP7.3 以及 TLS3,虽然是 beta 不过还是咬咬牙上了 233。
在这个过程中,遇到了 Acme.sh 签发泛域名证书的一些坑,第一次不知道为什么没有签署为通配符证书,于是删除重建,这次是通配符证书没错了,但是只匹配了
*.jipai.moe
这就导致直接访问https://jipai.moe 上报了不信任错误,有理有据,你 jipai.moe 确实不在*.jipai.moe 的匹配范围内嘛。于是删了再来,这次终于签上了
*.jipai.moe;jipai.moe
匹配的证书!高兴地打滚!接下来就是修改 nginx 的 conf 让 nginx 把所有 HTTP 请求都转到 HTTPS 下,同时还要对
http://jipai.moe
https://jipai.moe
这种情况做 301 跳转到带 www 的。在这个过程中又发生了一件小插曲,目前全站有三个二级域名,每一个 conf 里都有一个 listen 80 然后 301 到 https 的配置,我试图用
server_name *.jipai.moe;
return 301 https://$server_name$request_uri;
这样的配置来达成一劳永逸的效果,结果失败了…
nginx 直接把 https://*.jipai.moe 扔给了浏览器,当场翻车。
总之,在浪费了大半天时间后,现有的服务都跑在了阿里云香港区上,目前来看食用速度良好,咕咕咕~
最后贴一下自己的 nginx 配置,存个档!
server
{
listen 80;
#listen [::]:80;
server_name jipai.moe;
return 301 https://www.$server_name$request_uri;
}
server
{
listen 80;
#listen [::]:80;
server_name www.jipai.moe;
return 301 https://$server_name$request_uri;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name jipai.moe;
return 301 https://www.$server_name$request_uri;
ssl_certificate /usr/local/nginx/conf/ssl/jipai.moe/fullchain.cer;
ssl_certificate_key /usr/local/nginx/conf/ssl/jipai.moe/jipai.moe.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name jipai.moe *.jipai.moe;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/www.jipai.moe;
ssl_certificate /usr/local/nginx/conf/ssl/jipai.moe/fullchain.cer;
ssl_certificate_key /usr/local/nginx/conf/ssl/jipai.moe/jipai.moe.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
include rewrite/none.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-contentuploadswp-includesimages)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gifjpgjpegpngbmpswf)$
{
expires 30d;
}
location ~ .*\.(jscss)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/jipai.moe.log;
}
server
{
listen 80;
#listen [::]:80;
server_name lab.jipai.moe;
return 301 https://$server_name$request_uri;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name blog.jipai.moe;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/lab.jipai.moe;
ssl_certificate /usr/local/nginx/conf/ssl/jipai.moe/fullchain.cer;
ssl_certificate_key /usr/local/nginx/conf/ssl/jipai.moe/jipai.moe.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
include rewrite/none.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-contentuploadswp-includesimages)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gifjpgjpegpngbmpswf)$
{
expires 30d;
}
location ~ .*\.(jscss)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/lab.jipai.moe.log;
}