Skip to content

Commit

Permalink
v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
d committed Jan 18, 2023
1 parent ac460e6 commit 5b3a07e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 21 deletions.
29 changes: 23 additions & 6 deletions conf/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

local _isdev = 'development' == tofu.ENV

TOFU_VERSION = tofu.VERSION
-- ------------------------------------------------------------------------
--
--
Expand All @@ -17,28 +18,44 @@ local _isdev = 'development' == tofu.ENV
-- default_state = 0
--



-- -------------------------------------------------------------------------
-- nginx 配置文件 tofu.nginx.conf
--
--
-- 这些配置可在 tofu.nginx.conf 使用${xxx}获取,只支持基础类型(string, int, boolean, number)
-- 如定义端口,日志等等...
-- 约定以变量名以 ngx_ 开头
-- 约定以变量名以 ngx_ 开头,属于tofu.nginx.conf
--
-- 定义端口
ngx_port = 9527
ngx_error_log = _isdev and '/dev/stdout' or 'logs/error.log info'

-- 日志,当开发环境时输出到终端方便调试
ngx_error_log = _isdev and '/dev/stdout warn' or 'logs/error.log warn'

-- 约定以 _EXP 结尾的为完整的nginx配置项
ngx_worker_shutdown_timeout_EXP = _isdev and 'worker_shutdown_timeout 1;' or ''
ngx_user_EXP = '## user nobody;'

-- ngx 的启动用户
-- 一般都不需要指定
-- 如有碰到用户权限错误,可根据系统环境指定
-- 如:
-- ngx_user_EXP = 'user nginx;'
--
-- ngx_user_EXP = 'user nginx;'
--
-- 也可以根据tofu.ENV环境指定
-- ngx_user_EXP = _isdev and 'user '..tofu.ENV_USER..';' or '## user nobody;'


-- 运行时目录
-- 运行时目录,存放一些生成的配置和临时文件
-- ngx_runtime_dir = '.runtime'
--
-- 如需要更高级的控制,开启 lua-resty-template 模板支持
-- 依赖: bungle/lua-resty-template
-- 在 tofu.package.lua 中添加依赖: bungle/lua-resty-template
-- 然后执行 ./tofu install 安装所需的依赖
-- ngx_conf_file_template = false
--



2 changes: 1 addition & 1 deletion conf/extend.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extend = {
default = {
handle = 'resty.tofu.extend.config',
options = {
env = tofu.env,
env = tofu.ENV,
prefix = tofu.ROOT_PATH .. 'conf/',
}
}
Expand Down
35 changes: 25 additions & 10 deletions conf/tofu.nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pid ${ngx_runtime_dir}/nginx.pid;

##
env NGX_ENV;
env USER;


events {
Expand Down Expand Up @@ -73,7 +74,7 @@ http {
## log_escape_non_ascii off;
## log_subrequest on;

log_format main escape=json '$time_local $status $request_time $remote_addr $request ';
log_format main escape=json '$time_local $status $request_time $http_x_forwarded_for $request ';
## log_format main escape=json ' ';


Expand Down Expand Up @@ -111,6 +112,7 @@ http {
server {
## default port 9527
listen ${ngx_port};
listen [::]:${ngx_port};
root www;


Expand All @@ -126,21 +128,34 @@ http {

## access_log /dev/stdout main;
access_log off;
log_not_found off;


location = /favicon.ico {
log_not_found off;
access_log off;
}
## location ~ \.html$ {
## add_header Cache-Control no-store;
## add_header Pragma no-cache;
## expires 0;
## }


location ~ \.html$ {
add_header Cache-Control no-store;
add_header Pragma no-cache;
expires 0;
return 404;
}


location /favicon.ico {
return 404;
}


location ~* \.(php|jsp|asp|aspx)$ {
## deny all;
return 404;
}





##
## tofu framework start ...
Expand Down Expand Up @@ -168,11 +183,11 @@ http {
##
##
error_page 404 @err_x;
error_page 500 @err_x;
error_page 500 502 503 504 @err_x;

location @err_x {
content_by_lua_block {
ngx.print('<center><h1>'..ngx.var.status..'</h1><hr><p>tofu | openresty<p></center>')
ngx.print('<center><h1>'..ngx.var.status..'</h1><hr><p>tofu-${TOFU_VERSION} | openresty<p></center>')
}
}

Expand Down
6 changes: 2 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

```sh
## 从github中clone
git clone --depth=1 https://github.com/d80x86/tofu-project-default.git new_name
git clone --depth=1 https://github.com/d80x86/tofu-project-default.git new_project_name

## 进入项目
cd new_name
cd new_project_name

## 安装tofu framework
./tofu install
Expand All @@ -32,8 +32,6 @@ cd new_name
## 移除无用的旧git信息
rm -rf .git

## 添加
echo '/lua_modules' >> .gitignore
```


Expand Down

0 comments on commit 5b3a07e

Please sign in to comment.