Skip to content

Commit

Permalink
✨ feat: 对$进行转义操作
Browse files Browse the repository at this point in the history
  • Loading branch information
nichuanfang committed Nov 6, 2023
1 parent 3ea7835 commit 5b343c8
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions linux/bash/step2/vps/deploy_nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,26 @@ http {
root /root/blog;
index index.html index.htm;
# 将缓存策略用if语句写在location里面,生效了
if (\$request_filename ~* .*\.(?:htm|html)$) {
if (\$request_filename ~* .*\.(?:htm|html)\$) {
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
if (\$request_filename ~* .*\.(?:js|css)$) {
if (\$request_filename ~* .*\.(?:js|css)\$) {
expires 30d;
}
if (\$request_filename ~* .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|woff|woff2|webp)$) {
if (\$request_filename ~* .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|woff|woff2|webp)\$) {
expires 30d;
}
# 修复null报错
rewrite ^/about/null$ / break;
rewrite ^/about/null\$ / break;
rewrite ^/null$ / break;
rewrite ^/null\$ / break;
# 修复博客页面404 break隐藏式跳转 更推荐
rewrite ^/post/(.*)?(?<!html)$ /post/$1.html break;
rewrite ^/post/(.*)?(?<!html)\$ /post/\$1.html break;
rewrite ^/api/articles/(.*)(.html.json)$ /api/articles/$1.json break;
rewrite ^/api/articles/(.*)(.html.json)\$ /api/articles/\$1.json break;
}
}
Expand Down Expand Up @@ -238,14 +238,14 @@ http {
root /root/docs;
index index.html index.htm;
# 将缓存策略用if语句写在location里面,生效了
if (\$request_filename ~* .*\.(?:htm|html)$) {
if (\$request_filename ~* .*\.(?:htm|html)\$) {
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
if (\$request_filename ~* .*\.(?:js|css)$) {
if (\$request_filename ~* .*\.(?:js|css)\$) {
expires 30d;
}
if (\$request_filename ~* .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|woff|woff2|webp)$) {
if (\$request_filename ~* .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|woff|woff2|webp)\$) {
expires 30d;
}
Expand Down Expand Up @@ -288,15 +288,15 @@ http {
#bitwarden
location / {
proxy_pass http://127.0.0.1:7006;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
location /notifications/hub {
proxy_pass http://127.0.0.1:7007;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
}
Expand Down Expand Up @@ -349,11 +349,11 @@ http {
proxy_redirect off;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/;
}
}
Expand All @@ -362,7 +362,7 @@ http {
listen 80;
server_name $1 *.$1;
#将请求转成https
rewrite ^(.*)$ https://$host$1 permanent;
rewrite ^(.*)$ https://\$host\$1 permanent;
}
}
Expand Down

0 comments on commit 5b343c8

Please sign in to comment.