Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Webサーバ勉強会 #60 - #76
Search
Hidetake Iwata
November 02, 2010
Technology
0
260
Webサーバ勉強会 #60 - #76
Webサーバ勉強会
https://atnd.org/events/9124
Hidetake Iwata
November 02, 2010
Tweet
Share
More Decks by Hidetake Iwata
See All by Hidetake Iwata
Rewrite Go error handling using AST transformation
int128
1
1.3k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.7k
認証の仕組みとclient-go credential plugin / authentication and client-go credential plugin
int128
7
7.5k
CLIでOAuth/OIDCを快適に利用する
int128
0
890
AppEngine × Spring Boot × Kotlin
int128
0
120
いつものJIRA設定
int128
1
190
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.8k
本番環境のリリースを自動化した話
int128
0
780
Swagger × Spring Cloud
int128
0
110
Other Decks in Technology
See All in Technology
AIの全社活用を推進するための安全なレールを敷いた話
shoheimitani
2
640
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
55
22k
SEQUENCE object comparison - db tech showcase 2025 LT2
nori_shinoda
0
290
VS CodeとGitHub Copilotで爆速開発!アップデートの波に乗るおさらい会 / Rapid Development with VS Code and GitHub Copilot: Catch the Latest Wave
yamachu
2
350
United Airlines Customer Service– Call 1-833-341-3142 Now!
airhelp
0
180
CDK Vibe Coding Fes
tomoki10
1
580
Sansanのデータプロダクトマネジメントのアプローチ
sansantech
PRO
0
230
Rethinking Incident Response: Context-Aware AI in Practice
rrreeeyyy
1
430
ソフトウェアQAがハードウェアの人になったの
mineo_matsuya
3
140
TableauLangchainとは何か?
cielo1985
1
160
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
10
130k
ポストコロナ時代の SaaS におけるコスト削減の意義
izzii
1
320
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Gamification - CAS2011
davidbonilla
81
5.4k
Rails Girls Zürich Keynote
gr2m
95
14k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.7k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Docker and Python
trallard
45
3.5k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Building Adaptive Systems
keathley
43
2.7k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Building an army of robots
kneath
306
45k
Transcript
Webサーバ勉強会 #60~#76 @int128 (いわてぃ)
Introduction @int128 http://d.hatena.ne.jp/int128/ ソフトウェア&インフラエンジニア 大きなSI屋で働いています。 自宅サーバが好きです。 最近、インフラ設計書を公開しました。
17 modules 60 mod_actions 61 mod_speling 62 mod_userdir 63 mod_alias
64 mod_rewrite 65 mod_proxy 66 mod_proxy_balancer 67 mod_proxy_ftp 68 mod_proxy_http 69 mod_proxy_connect 70 mod_cache 71 mod_suexec 72 mod_disk_cache 73 mod_file_cache 74 mod_mem_cache 75 mod_cgi 76 mod_version そんな時間配分で大丈夫か? 16秒 × 17 modules =272秒
大丈夫だ、問題ない
Agenda 独断と偏見で並び替えてお送りします。 1. mod_alias 2. mod_userdir 3. mod_rewrite 4. mod_proxy
(http/ftp/connect/balancer) 5. mod_cache (mem/disk), mod_file_cache 6. mod_cgi 7. mod_suexec 8. mod_actions 9. mod_speling 10. mod_version
(1) mod_alias ドキュメントツリーにファイルシステムをマップする。 Alias /images /misc/data/images # Order allow, denyをお忘れなく
AliasMatch ←Aliasの正規表現 Redirect RedirectMatch RedirectPermanent ←301を返す RedirectTemp ←302を返す ScriptAlias ←Aliasのcgi-script版 ScriptAliasMatch
(2) mod_userdir ユーザのホームディレクトリを公開するためのモジュール。 UserDir public_html http://example.com/~int128/index.html →/home/int128/public_html/index.html 絶対パスでもOK。(例: /var/www/home) パスは複数候補を書ける。
UserDir disabled UserDir enabled user1 user2 user3 特定のユーザだけホームディレクトリを有効にできる
(3) mod_rewrite ルールに基づいてURLを書き換える機能を提供する。 RewriteCondで条件式、 RewriteRuleで動作(リライト、リダイレクト)を指定する。 RewriteCond %{HTTP_USER_AGENT} DoCoMo [OR] RewriteCond
%{HTTP_USER_AGENT} SoftBank RewriteRule ^/$ /mobile/ [L] 携帯電話からトップページへのアクセスはケータイコンテンツを返す。 使いすぎに注意。ご利用は計画的に。 JMeterでテスト駆動構築がおすすめ。
(4) mod_proxy リバースプロキシ、フォワードプロキシを提供する。 リバースプロキシ DMZからTrustへのリクエスト転送に使う。 mod_proxy_balancerを組み合わせると ロードバランスも可能。 フォワードプロキシ TrustからインターネットにGETする場合など。 mod_proxy自体はキャッシュしてくれない。
クライアント mod_proxy httpd httpd
(4) mod_proxy (続き) 必要なプロトコルを組み合わせて LoadModule すればおk • mod_proxy (本体) ◦
mod_proxy_http (HTTPプロキシ) ◦ mod_proxy_connect (SSL/CONNECTプロキシ) ◦ mod_proxy_ftp (FTPプロキシ) ◦ mod_proxy_ajp (AJPプロキシ) • mod_proxy_balancer (ロードバランサ) ProxyPass /ap http://172.16.3.1/ap ProxyPassReverse /ap http://172.16.3.1/ap タイムアウト、フェイルオーバ時間に注意する。 (上位LBを含めた)シーケンス図を書いて整理するとよい。
(5) mod_cache RFC2616のコンテンツキャッシュ制御を提供する。 •mod_disk_cache (ディスクキャッシュ) •mod_mem_cache (メモリキャッシュ) デフォルトでは、クエリ無しで、レスポンスヘッダに Last-Modified, Expires,
ETag のいずれかが付いていればキャッシュする。 リバースプロキシの性能を飛躍的に向上できる。 ただし、キャッシュされる条件、有効期限に注意すべし。
ちなみに、mod_file_cache 起動時にファイルをメモリに読み込むことで高速化するモジュール。 mod_cacheとは別物。 2つの方式を選べる。 •起動時にファイルをmmap()しておく。 •起動時にファイルのファイルハンドルを開いておく。 キャッシュを更新するにはhttpdの再起動が必要。 Experimentalだし使わない方がいいかも。
(6) mod_cgi CGIを使うためのモジュール。 worker MPMではmod_cgidを使う。 以下のディレクティブが使えるようになる。 AddHandler cgi-script .cgi Options
+ExecCGI AcceptPathInfo on ScriptAlias /cgi-bin /var/www/cgi-bin ScriptLog /var/log/apache2/cgi_log
(7) mod_suexec CGIをユーザアカウントで実行する機能を提供する。 例えば、 http://example.com/~int128/index.cgi というリクエストを受けたとき、スクリプトを •apacheユーザで実行する。 ←suEXEC無効 •int128ユーザで実行する。 ←suEXEC有効
suEXECありでビルドされたApacheでのみ使える。 ディレクトリやスクリプトのパーミッションがチェックされる。 期待通り動かないときは suexec_log を参照。
(8) mod_actions メディアタイプやリクエストメソッドに応じて CGI スクリプトを実行す る機能を提供する。 Action application/x-httpd-php5 /cgi-bin/php.cgi AddHandler
application/x-httpd-php5 .php5 *.php5へのリクエストはCGIスクリプトを起動する。 さくらサーバで野良PHPを使うためにActionディレクティブを使った など。
(9) mod_speling リクエストURIのスペルミスを訂正して、それっぽいリソースを返し てくれるモジュール。大文字小文字の間違い、1文字の誤りを訂正 する。 CheckSpelling on やってみた。 •間違ったURLを叩くと、正しいURLにリダイレクトされる。 •候補が複数ある場合は選択ページ(英語)が表示される。
•クエリパラメータには効かない。
(10) mod_version バージョンに依存する設定を書くためのモジュール。 <IfVersion >= 2.2> # Settings for httpd
2.2 or later </IfVersion> 正規表現も使える。 <IfVersion = /2.2.1[123]/> # Workaround for httpd 2.2.11~13 </IfVersion>
ご清聴ありがとうございました 一番いいconfigを頼む