ユーザ用ツール

サイト用ツール


nginx

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
nginx [2012/06/05 02:41] – [PHP] nullponnginx [2020/05/29 09:30] (現在) nullpon
行 1: 行 1:
 ====== nginx ====== ====== nginx ======
-非同期IOで動作する高速なHTTPサーバ。+非同期IOで動作する高速なHTTPサーバ。読み方は「えんじんえっくす」
  
  
行 80: 行 80:
  
  
-===== passenger ===== 
-nginx + passenger でrailsアプリを起動する。 
- 
-Ubuntu 10.04では以下のライブラリをインストールする 
- 
-<code> 
-$ sudo aptitude install build-essential 
-$ sudo aptitude install libcurl4-openssl-dev 
-</code> 
- 
-rubyやgem、rails等のインストール後、gemでpassengerをインストール。ここではバージョンを明示しているが、特に指定せず最新版を入れると良い。 
- 
-<code> 
-$ sudo gem install -v=3.0.7 passenger --no-rdoc --no-ri 
-$ sudo /var/lib/gems/1.8/gems/passenger-3.0.7/bin/passenger-install-nginx-module 
-</code> 
- 
-とりあえず起動と停止 
- 
-<code> 
-$ sudo /opt/nginx/sbin/nginx  
-$ sudo /opt/nginx/sbin/nginx -s stop 
-</code> 
- 
-Railsアプリの実行ユーザはAapche版と同じく environment.rb の所有ユーザとなる。 
  
 ==== nginx.confに設定を追加 ==== ==== nginx.confに設定を追加 ====
行 267: 行 242:
 </code> </code>
  
 +===== x-accel-redirect =====
 +
 +nginx をバックエンドアプリケーションのプロキシとして使っている場合に、アプリにproxyした後にnginxがファイルを返すようにする仕組み。
 +
 +主な用途は認証つきの静的ファイルダウンロード。nginxがファイルを返すためバックエンドアプリケーションに転送負荷をかけずに認証つきのファイルダウンロードを実装できる
 +
 +アプリ側は権限などのチェックを行い、問題なければ200レスポンスに以下のようなレスポンスヘッダをつける
 +
 +<code>
 +X-Accel-Redirect: /download/fifename1.png
 +</code>
 +
 +nginx側
 +
 +<code>
 +// アプリへのプロキシ
 +location / {
 +  proxy_pass: http://127.0.0.1:8080 
 +}
 +
 +// x-accel-redirectを受け取る部分
 +location /download {
 +  internal;   // これを忘れると直接パス指定でダウンロードし放題になるので注意
 +  root /var/www/download;
 +}
 +</code>
 +
 +ダウンロードさせるファイルは ''/var/www/download/'' 以下に設置する
nginx.1338864069.txt.gz · 最終更新: 2012/06/05 02:41 by nullpon