Files
tlmall-v5-single/doc/nginx/nginx.conf
USER-20221017CE\Administrator d31fad2aa9 初始化提交
2022-11-01 12:14:54 +08:00

94 lines
2.6 KiB
Nginx Configuration File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

worker_processes 7; #nginx worker 数量
error_log logs/error.log; #指定错误日志文件路径
events {
worker_connections 1024;
}
http {
include mime.types;
# 这个将为打开文件指定缓存默认是没有启用的max 指定缓存数量,
# 建议和打开文件数一致inactive 是指经过多长时间文件没被请求后删除缓存。
open_file_cache max=100 inactive=30s;
# open_file_cache 指令中的inactive 参数时间内文件的最少使用次数,
# 如果超过这个数字,文件描述符一直是在缓存中打开的,如上例,如果有一个
# 文件在inactive 时间内一次没被使用,它将被移除。
open_file_cache_min_uses 1;
# 这个是指多长时间检查一次缓存的有效信息
open_file_cache_valid 60s;
#开启高效文件传输模式
sendfile on;
#提高I/O性能
tcp_nodelay on;
access_log logs/access.log;
#lua 模块
lua_package_path "/usr/local/openresty/lua/?.lua;/usr/local/openresty/lualib/?.lua;;";
#c模块
lua_package_cpath "/usr/local/openresty/lualib/?.so;;";
lua_code_cache on;
# 共享字典也就是本地缓存名称叫做stock_cache大小1m
lua_shared_dict stock_cache 1m;
#秒杀确认页相关负载均衡
upstream confirm {
server 192.168.65.155:8855;
}
#秒杀订单相关负载均衡
upstream order {
server 192.168.65.133:8844;
}
server {
#监听端口
listen 80;
charset utf-8;
set $template_root /usr/local/openresty/tpl;
location /test {
default_type text/html;
content_by_lua_block {
ngx.say("泰勒斯说万物充满了神明,是让我们把神明拉下神座,从此诸神迎来了他们的黄昏")
}
}
#产品静态模板化网页访问
location /product {
default_type text/html;
content_by_lua_file lua/product.lua;
}
#静态资源访问
location /static {
root /usr/local/openresty;
index index.html index.htm;
}
#秒杀确认页反向代理
location /skcart {
proxy_pass http://confirm;
}
#秒杀订单反向代理
location /seckillOrder {
proxy_pass http://order;
}
#秒杀产品当前库存
location /cache/stock {
# 默认的响应类型
default_type application/json;
# 响应结果由lua/stock.lua文件来处理
content_by_lua_file lua/stock.lua;
}
}
}