lua服务器读写文件,nginx + lua 搭建静态文件服务器 lua utf8 转 gb2312

#user nobody;

worker_processes 4;

error_log /var/log/nginx/error.log info;

pid logs/nginx.pid;

worker_rlimit_nofile 50000;

events {

use epoll;

worker_connections 50000;

}

http {

include mime.types;

default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;

sendfile_max_chunk 256K;

tcp_nopush on;

log_not_found off;

open_file_cache max=1024 inactive=60s;

open_file_cache_valid 60s;

open_file_cache_min_uses 2;

open_file_cache_errors on;

keepalive_timeout 0;

gzip on;

server_tokens off;

client_max_body_size 256m;

client_body_temp_path /dev/shm/client_body_temp 1 2;

fastcgi_temp_path /dev/shm/fastcgi_temp 1 2;

proxy_temp_path /dev/shm/proxy_temp 1 2;

lua_package_path '/usr/local/share/luajit-2.0.3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/socket/?.lua;;';

lua_package_cpath '/usr/local/lib/lua/5.1/?.so;;';

init_by_lua 'iconv, cjson, redis = require "iconv", require "cjson", require "redis"';

server {

listen 80;

server_name static.******.com;

root /var/static.******.com;

set $script_path '/var/static.******.com/scripts';

location / {

return 403;

}

location = /crossdomain.xml {

#Flash request require this file.

}

location = /up {

access_by_lua 'ngx.req.set_uri("/scripts/upload_script.php")';

include fastcgi.conf;

}

location = /accessToken {

access_by_lua 'ngx.req.set_uri("/scripts/accessToken_script.php")';

include fastcgi.conf;

}

location ~ ^/([^\/]+)/([\w]+)/info$ {

default_type "application/json";

set $domain $1;

set $fn $2;

access_by_lua_file $script_path/info.lua;

}

location ~ ^/([^\/]+)/([\w]+)$ {

set $domain $1;

set $fn $2;

access_by_lua_file $script_path/stream_and_download.lua;

}

location ~ ^/([^\/]+)/([\w]+)/([\d]+)/([\d]+)$ {

set $domain $1;

set $fn $2;

set $width $3;

set $height $4;

access_by_lua_file $script_path/image_filter.lua;

image_filter resize $width $height;

}

location ~ "^/([^\/]+)/([\w]{2})([\w]{2})([\w]{2})([\w]{26})\.flv$" {

try_files /$1/$2/$3/$4/$2$3$4$5.flv =404;

flv;

}

location ~ "^/([^\/]+)/([\w]{2})([\w]{2})([\w]{2})([\w]{26})\.mp4$" {

try_files /$1/$2/$3/$4/$2$3$4$5.mp4 =404;

mp4;

mp4_buffer_size 1m;

mp4_max_buffer_size 5m;

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值