# ngx_mruby configuration
worker_processes auto;
events {
worker_connections 1024;
}
http {
# mruby handlers using external files
mruby_init /etc/nginx/mruby/init.rb;
mruby_init_worker /etc/nginx/mruby/init_worker.rb;
server {
listen 80;
server_name mruby.example.com;
# Content handler with external file
location /hello {
mruby_content_handler /etc/nginx/mruby/hello.rb;
}
# Access control with external file
location /api {
mruby_access_handler /etc/nginx/mruby/access_check.rb;
proxy_pass http://127.0.0.1:8080;
}
# Rewrite handler
location /legacy {
mruby_rewrite_handler /etc/nginx/mruby/rewrite.rb;
}
# Log handler
location /tracked {
mruby_log_handler /etc/nginx/mruby/log.rb;
proxy_pass http://127.0.0.1:8080;
}
# Set variable with mruby
location /dynamic {
mruby_set $backend /etc/nginx/mruby/select_backend.rb;
proxy_pass http://$backend;
}
# Output filter
location /filtered {
mruby_output_filter /etc/nginx/mruby/filter.rb;
proxy_pass http://127.0.0.1:8080;
}
location / {
root /var/www/html;
index index.html;
}
}
}