Debian11上安装Nginx并配置HTTPS
Debian11上安装Nginx并配置HTTPS
reference-site-list
steps
安装Nginx
1 2 3 4 5 6
| apt-get update
apt-get install nginx
systemctl enable nginx
|
使用acme进行HTTPS配置
- 向阿里云获取AccessKey
阿里云获取AccessKey
- 使用acme申请证书
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| cd /etc/nginx mkdir cert.d cd cert.d mkdir xplorist.tech
cd /data
curl https://get.acme.sh | sh
vi ~/.bashrc
export Ali_Key="AccessKeyId" export Ali_Secret="AccessKeySecret"
source ~/.bashrc
acme.sh --issue --dns dns_ali -d xplorist.tech -d *.xplorist.tech --server letsencrypt
crontab -l
acme.sh --issue --dns dns_ali -d xplorist.tech -d *.xplorist.tech \ --server letsencrypt \ --installcert \ --key-file /etc/nginx/cert.d/xplorist.tech/key.pem \ --fullchain-file /etc/nginx/cert.d/xplorist.tech/full.pem \ --reloadcmd "nginx -s reload"
|
配置Nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| vi /etc/nginx/nginx.conf
vi /etc/nginx/conf.d/xplorist.tech.conf
server { listen 80; server_name xplorist.tech; client_max_body_size 1024m;
rewrite ^(.*)$ https://${server_name}$1 permanent;
error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
server { listen 443 ssl http2; server_name xplorist.tech; client_max_body_size 1024m;
ssl_certificate /etc/nginx/cert.d/xplorist.tech/full.pem; ssl_certificate_key /etc/nginx/cert.d/xplorist.tech/key.pem;
ssl_session_timeout 5m;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384; ssl_protocols TLSv1.3 TLSv1.2; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m;
location / { root /usr/share/nginx/html; index index.html index.htm index.php; }
location ~ \.php$ { root /usr/share/nginx/html; include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.3-fpm.sock; } }
|
- 本文标题:Debian11上安装Nginx并配置HTTPS
- 本文作者:Xplorist
- 创建时间:2021-11-09 13:27:00
-
本文链接:https://xplorist.tech/2021/11/09/857bfb0cf50a/
-
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
$tools-item-width = 2.2rem
$tools-item-font-size = 1.1rem
$tools-item-border-radius = 0.1rem
.side-tools-container {
position relative
.tools-item {
width $tools-item-width
height $tools-item-width
margin-bottom 0.2rem
color var(--default-text-color)
font-size $tools-item-font-size
background var(--background-color)
border-right none
border-radius $tools-item-border-radius
box-shadow 0.1rem 0.1rem 0.2rem var(--shadow-color)
cursor pointer
i {
color var(--default-text-color)
}
&:hover {
color var(--background-color)
background var(--primary-color)
box-shadow 0.2rem 0.2rem 0.4rem var(--shadow-color)
i {
color var(--background-color)
}
}
+keep-tablet() {
width $tools-item-width * 0.9
height $tools-item-width * 0.9
margin-bottom 0.2rem
font-size $tools-item-font-size * 0.9
}
&.rss {
a {
width 100%
height 100%
border-radius $tools-item-border-radius
&:hover {
color var(--background-color)
background var(--primary-color)
box-shadow 0.2rem 0.2rem 0.4rem var(--shadow-color)
}
}
}
}
.side-tools-list {
transform translateX(100%)
opacity 0
transition-t("transform, opacity", "0, 0", "0.2, 0.2", "linear, linear")
.tool-expand-width {
+keep-tablet() {
display none
}
}
&.show {
transform translateX(0)
opacity 1
}
}
.exposed-tools-list {
if (hexo-config('style.scroll.percent.enable') == true) {
.tool-scroll-to-top {
display none
&.show {
display flex
}
&:hover {
.percent {
display none
}
.arrow-up {
display flex
}
}
.arrow-up {
display none
}
.percent {
display flex
font-size 1rem
}
}
}
}
}