enhance: block template parser

This commit is contained in:
0xJacky 2023-04-10 23:43:34 +08:00
parent f36e582976
commit f15e66e0de
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
20 changed files with 249 additions and 108 deletions

View file

@ -1,8 +1,7 @@
# Nginx UI Template Start
# Name: Codeigniter Rewrite
# Description[en]: Codeigniter URL Rewrite Config
# Description[zh_CN]: Codeigniter 伪静态配置
# Author: @0xJacky
name = "Codeigniter Rewrite"
author = "@0xJacky"
description = { en = "Codeigniter URL Rewrite Config", zh_CN = "Codeigniter 伪静态配置"}
# Nginx UI Template End
location / {
try_files $uri $uri/ /index.php;

View file

@ -1,8 +1,7 @@
# Nginx UI Template Start
# Name: PHP8.1
# Description[en]: Enabled PHP 8.1 Config
# Description[zh_CN]: 启用 PHP 8.1 配置
# Author: @0xJacky
name = "PHP8.1"
author = "@0xJacky"
description = { en = "Enabled PHP 8.1 Config", zh_CN = "启用 PHP 8.1 配置"}
# Nginx UI Template End
location ~ [^/]\.php(/|$)
{

View file

@ -1,7 +1,17 @@
# Nginx UI Template Start
# Name: HSTS
# Description[en]: Enable HTTP Strict Transport Security
# Description[zh_CN]: 启用 HTTP 严格传输安全
# Author: @0xJacky
name = "HSTS"
author = "@0xJacky"
description = { en = "Enable HTTP Strict Transport Security", zh_CN = "启用 HTTP 严格传输安全"}
[variables.maxAge]
type = "string"
name = { en = "Max Age", zh_CN = "有效时间"}
value = "31536000"
[variables.includeSubDomains]
type = "boolean"
name = { en = "Include sub domains", zh_CN = "包括子域名"}
value = true
# Nginx UI Template End
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header Strict-Transport-Security "max-age={{.maxAge}}; {{if .includeSubDomains}} includeSubDomains {{end}}" always;

View file

@ -1,7 +1,6 @@
# Nginx UI Template Start
# Name: HTTP to HTTPS
# Description[en]: HTTP force redirect to HTTPS Config
# Description[zh_CN]: HTTP 强制跳转 HTTPS 配置
# Author: @0xJacky
name = "HTTP to HTTPS"
author = "@0xJacky"
description = { en = "HTTP force redirect to HTTPS Config", zh_CN = "HTTP 强制跳转 HTTPS 配置"}
# Nginx UI Template End
return 307 https://$server_name$request_uri;

View file

@ -1,8 +1,7 @@
# Nginx UI Template Start
# Name: Laravel Rewrite
# Description[en]: Laravel URL Rewrite Config
# Description[zh_CN]: Laravel 伪静态配置
# Author: @0xJacky
name = "Laravel Rewrite"
author = "@0xJacky"
description = { en = "Laravel URL Rewrite Config", zh_CN = "Laravel 伪静态配置"}
# Nginx UI Template End
location / {
try_files $uri $uri/ /server.php?$query_string;

View file

@ -1,13 +1,12 @@
# Nginx UI Template Start
# Name: Let's Encrypt
# Description[en]: Let's Encrypt HTTPChallange
# Description[zh_CN]: Let's Encrypt HTTP 鉴权
# Author: @0xJacky
name = "Let's Encrypt"
author = "@0xJacky"
description = { en = "Let's Encrypt HTTPChallange", zh_CN = "Let's Encrypt HTTP 鉴权"}
# Nginx UI Template End
location /.well-known/acme-challenge {
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
proxy_pass http://127.0.0.1:{{ HTTP01PORT }};
proxy_pass http://127.0.0.1:{{.HTTP01PORT}};
}

View file

@ -1,8 +1,7 @@
# Nginx UI Template Start
# Name: Nginx UI
# Description[en]: Nginx UI Config Template
# Description[zh_CN]: Nginx UI 配置模板
# Author: @0xJacky
name = "Nginx UI"
author = "@0xJacky"
description = { en = "Nginx UI Config Templateg", zh_CN = "Nginx UI 配置模板"}
# Nginx UI Template End
# Nginx UI Custom Start
@ -19,5 +18,5 @@ location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:9000/;
proxy_pass http://127.0.0.1:{{.HTTPPORT}}/;
}

View file

@ -1,15 +1,48 @@
# Nginx UI Template Start
# Name: Reverse Proxy
# Description[en]: Reverse Proxy Config
# Description[zh_CN]: 反向代理配置
# Author: @0xJacky
name = "Reverse Proxy"
author = "@0xJacky"
description = { en = "Reverse Proxy Config", zh_CN = "反向代理配置"}
[variables.enableWebSocket]
type = "boolean"
name = { en = "Enable WebSocket", zh_CN = "启用 WebSocket"}
value = true
[variables.clientMaxBodySize]
type = "string"
name = { en = "Include sub domains", zh_CN = "客户端最大请求内容大小"}
value = "1000m"
[variables.port]
type = "string"
name = { en = "Port", zh_CN = "端口"}
value = 9000
# Nginx UI Template End
# Nginx UI Custom Start
{{- if .enableWebSocket }}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
{{- end }}
# Nginx UI Custom End
location / {
proxy_pass http://127.0.0.1:9000/;
{{ if .enableWebSocket }}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
{{ end }}
client_max_body_size {{ .clientMaxBodySize }};
proxy_redirect off;
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;
client_max_body_size 1000m;
proxy_pass http://127.0.0.1:{{ .port }}/;
}

View file

@ -1,26 +0,0 @@
# Nginx UI Template Start
# Name: Reverse Proxy WebSocket
# Description[en]: Reverse Proxy with WebSocket Config
# Description[zh_CN]: 反向代理 WebSocket 配置
# Author: @0xJacky
# Nginx UI Template End
# Nginx UI Custom Start
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Nginx UI Custom End
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:9000/;
proxy_redirect off;
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;
client_max_body_size 1000m;
}

View file

@ -1,8 +1,7 @@
# Nginx UI Template Start
# Name: WordPress
# Description[en]: WordPress Config Template
# Description[zh_CN]: WordPress 配置模板
# Author: @0xJacky
name = "WordPress"
author = "@0xJacky"
description = { en = "WordPress Config Template", zh_CN = "WordPress 配置模板"}
# Nginx UI Template End
location / {
try_files $uri $uri/ /index.php?$args;