Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
Last active December 23, 2015 21:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sawanoboly/6696194 to your computer and use it in GitHub Desktop.
Save sawanoboly/6696194 to your computer and use it in GitHub Desktop.
For Opscode chef. Enjoy ngx_mruby!
192.168.2.1
192.168.2.2
{
"run_list" : [
"recipe[build-essential::default]",
"recipe[mruby::ngx_mruby]",
"recipe[nginx]"
],
"mruby": {
"force_rebuild" : true,
"build_options" : {
"user_gems" : [
[":git", "https://github.com/iij/mruby-io.git"],
[":git", "https://github.com/iij/mruby-socket.git"],
[":git", "https://github.com/iij/mruby-pack.git"],
[":git", "https://github.com/iij/mruby-ipaddr.git"]
]
}
},
"nginx" : {
"install_method" : "source",
"version" : "1.4.2",
"configure_flags" : [
"--with-debug"
],
"source" : {
"modules" : [
"http_ssl_module",
"http_geoip_module",
"http_realip_module",
"http_stub_status_module",
"http_gzip_static_module"
]
}
}
}
server {
listen 80;
server_name mruby-nginx;
access_log /var/log/nginx/localhost.access.log;
root /var/www/nginx-default;
index index.html index.htm;
location /403 {
return 403;
}
location / {
mruby_set_code $deny '
r = Nginx::Request.new()
filename = File.join(r.var.document_root, ".ht_ngx_access")
if File.exists?(filename)
deny_list = Array.new
File.open(filename) do |file|
while line = file.gets
deny_list << line.chomp
end
end
if deny_list.include?(r.var.remote_addr)
Nginx.errlogger Nginx::LOG_ERR, "ACL: Client Matched!!"
"denied"
else
Nginx.errlogger Nginx::LOG_ERR, "ACL: Client Unmatched"
""
end
else
""
end
';
if ($deny) {
return 403;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment