Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h2oを試す #18

Open
fukuiretu opened this issue Jul 22, 2015 · 19 comments
Open

h2oを試す #18

fukuiretu opened this issue Jul 22, 2015 · 19 comments

Comments

@fukuiretu
Copy link
Member

No description provided.

@fukuiretu
Copy link
Member Author

とりあえずMac上で動かしてみた

ref: http://blog.sarabande.jp/post/115987488918

@fukuiretu
Copy link
Member Author

Next: リバプロでRailsまで

@fukuiretu
Copy link
Member Author

ローカルでunicorn起動
unicorn_rails -c config/unicorn.rb -E development -p 5000 -D

@fukuiretu
Copy link
Member Author

ref: h2oとUnixドメインソケット http://qiita.com/cubicdaiya/items/d6f3a165fa29e199afb1

@fukuiretu
Copy link
Member Author

tcpのリバプロは以下の設定でいけた

/usr/local/etc/h2o/h2o.conf

listen:
  port: 8080
hosts:
  default:
    paths:
      /static:
        file.dir: /usr/local/var/h2o/
      /:
        proxy.reverse.url: http://127.0.0.1:5000/
    access-log: /dev/stdout

@fukuiretu
Copy link
Member Author

以下の設定でunixドメインソケットでリバプロしたらfailed to connect to hostと言われた...

listen:
  port: 8080
hosts:
  default:
    paths:
      /static:
        file.dir: /usr/local/var/h2o/
      /:
        proxy.reverse.url: http://[unix:/tmp/ikyusan-api_unicorn.sock]/
    access-log: /dev/stdout

@fukuiretu
Copy link
Member Author

unicronをtcpで起動してたからあかんかった。。いけたぞーーーー。あとh2oのソース見たら、reproxy: ONっての付けてたので、最終的に以下のようになった。

listen:
  port: 8080
hosts:
  default:
    paths:
      /static:
        file.dir: /usr/local/var/h2o/
      /:
        proxy.reverse.url: http://[unix:/tmp/ikyusan-api_unicorn.sock]/
    access-log: /dev/stdout
reproxy: ON

@fukuiretu
Copy link
Member Author

nginxでいうところのほげほげ的な設定値周り調べる

refs:

@fukuiretu
Copy link
Member Author

設定は公式読み解いたほうがよさそうだ
https://h2o.examp1e.net/configure.html

@fukuiretu
Copy link
Member Author

調査ポイント

アクセス制限
エラーページ

この辺りは、mruby使えばどうとでもなりそう。拡張モジュールをrubyでかけるのまじcoolだ。

@fukuiretu
Copy link
Member Author

アクセスログのフォーマットをTSVなどに加工できるか

Try

↓こんな感じでいけた

access-log:
      path: "/dev/stdout"
      format: "host:%h\t%l\t%u\t%t\t\"%r\"\t%s\t%b\t\"%{Referer}i\"\t\"%{User-agent}i\""

@fukuiretu
Copy link
Member Author

ヘッダーに情報追加できるか. X-Forwarded-Forなど

Try

@fukuiretu
Copy link
Member Author

  • proxy.preserve-host: ONを追加
  • ログのフォーマットに\"%{X-Forwarded-For}i\"を追加

curl -H "X-Forwarded-For:192.22.192.11" http://localhost:8080/staticで叩いたら、
host:::1 - - [25/Jul/2015:06:58:29 +0900] "GET /static HTTP/1.1" 301 88 "-" "curl/7.37.1" "192.22.192.11"
で出てた

@fukuiretu
Copy link
Member Author

ぬ...makeでエラッタ。。。

/root/h2o/include/h2o/socket.h:31:25: fatal error: openssl/ssl.h: No such file or directory

yum install openssl-develしたらいけた

@fukuiretu
Copy link
Member Author

インストールDone.

yum groupinstall "Development Tools"
yum install cmake
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
yum --enablerepo=rpmforge install libyaml-devel
yum install openssl-devel
cd /usr/local/src
git clone https://github.com/kazuho/h2o.git
cd h2o
git submodule update --init --recursive
cmake .
make h2o
make install
/usr/local/bin/h2o -c /usr/local/share/h2o/h2o.conf &

@fukuiretu
Copy link
Member Author

Next: Vagrant上のh2oでリバプロ

@fukuiretu
Copy link
Member Author

Next: mrubyのインストール
ref: http://blog.matsumoto-r.jp/?p=3310

@fukuiretu
Copy link
Member Author

done.これはQiitaにまとめよう。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant