Last active
December 23, 2015 21:29
-
-
Save sawanoboly/6696194 to your computer and use it in GitHub Desktop.
For Opscode chef. Enjoy ngx_mruby!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
192.168.2.1 | |
192.168.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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