0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

H2Oを実戦投入するためのいろいろ

Posted at

下記で大体戦える
service h2o reloadで反映かな。

TOC

  • Basic認証
  • IP制限
  • 特定コンテンツの403対応 .gitなど

Basic認証

@h2o.cfg

        mruby.handler: |
          require "htpasswd.rb"
          Htpasswd.new("/path/to/.htpasswd", "Realm")  

IP制限

たとえば

192.168.1.10
127.0.0.1

のみを許可したい場合

@ip.rbとかつくって内容は

ALLOW_IPS = %w{
    192.168.1.10
127.0.0.1
}
class Acl
  def call(env)
    if ALLOW_IPS.include? env['REMOTE_ADDR']
      [399, {}, []]
    else
      [403, {'Content-Type' => 'text/plain;charset=utf-8'}, ['Forbidden']]
    end
  rescue => e
    $stderr.puts e
  end
end
Acl.new

@h2o.cfgには

     paths:
       "/":
         mruby.handler-file: /path/to/ip.rb
         file.dir: /var/www/html

とかする

特定コンテンツの403対応 .git、.htaccessなど

    paths:
       "/":
         mruby.handler: |
           acl {
              deny { path =~ /\.git+/ }
              deny { path =~ /\.ht+/ }
           }
         file.dir: /var/www/html
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?