• このエントリーをはてなブックマークに追加

はじめに

Homebrew で,nginx_tcp_proxy_module をつけて nginx を入れる手順のメモ.

参考

Formula を編集する

% brew edit nginx
diff --git a/Library/Formula/nginx.rb b/Library/Formula/nginx.rb
index 5dd5eb7..497f291 100644
--- a/Library/Formula/nginx.rb
+++ b/Library/Formula/nginx.rb
@@ -42,6 +42,7 @@ class Nginx < Formula
             "--with-ipv6",
             "--with-cc-opt=-I#{HOMEBREW_PREFIX}/include",
             "--with-ld-opt=-L#{HOMEBREW_PREFIX}/lib",
+            "--add-module=./nginx_tcp_proxy_module",
             "--conf-path=#{etc}/nginx/nginx.conf",
             "--pid-path=#{var}/run/nginx.pid",
             "--lock-path=#{var}/nginx/nginx.lock"]
@@ -49,6 +50,8 @@ class Nginx < Formula
     args << passenger_config_args if build.include? 'with-passenger'
     args << "--with-http_dav_module" if build.include? 'with-webdav'
 
+    system "git clone git://github.com/yaoweibin/nginx_tcp_proxy_module"
+    system "patch -p1 < ./nginx_tcp_proxy_module/tcp.patch"
     system "./configure", *args
     system "make"
     system "make install"

インストールする

あとはインストールするだけ(同じバージョンが既に入っている場合は, brew uninstall nginx するしかないのかなぁ):

% brew install nginx
==> Downloading http://nginx.org/download/nginx-1.2.3.tar.gz
Already downloaded: /Library/Caches/Homebrew/nginx-1.2.3.tar.gz
==> Patching
patching file conf/nginx.conf
==> git clone git://github.com/yaoweibin/nginx_tcp_proxy_module
==> patch -p1 < ./nginx_tcp_proxy_module/tcp.patch
==> ./configure --prefix=/usr/local/Cellar/nginx/1.2.3 --with-http_ssl_module --with-pcre --with-ipv6 --with-cc-opt=-I/usr/local/include --with-ld-opt=-L/usr/local/lib --add-module=./nginx_tcp_proxy_module --conf-path=/usr/local/e
==> make
==> make install
==> Caveats
In the interest of allowing you to run `nginx` without `sudo`, the default
port is set to localhost:8080.
 
If you want to host pages on your local machine to the public, you should
change that to localhost:80, and run `sudo nginx`. You'll need to turn off
any other web servers running port 80, of course.
 
You can start nginx automatically on login running as your user with:
  mkdir -p ~/Library/LaunchAgents
  cp /usr/local/Cellar/nginx/1.2.3/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
 
Though note that if running as your user, the launch agent will fail if you
try to use a port below 1024 (such as http's default of 80.)
==> Summary
/usr/local/Cellar/nginx/1.2.3: 9 files, 984K, built in 21 seconds

成功!

% nginx -V
nginx version: nginx/1.2.3
built by clang 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.2.3 --with-http_ssl_module --with-pcre --with-ipv6 --with-cc-opt=-I/usr/local/include --with-ld-opt=-L/usr/local/lib --add-module=./nginx_tcp_proxy_module --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/nginx/nginx.lock

入ってるっぽいですね!

おわりに

さて,nginx で WebSocket が使えるように設定ができるかどうか,それが問題です><