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
httpd.conf programming
Search
jeffhung
April 20, 2013
Programming
1
310
httpd.conf programming
My Lightning talk in OSDC.tw 2013
jeffhung
April 20, 2013
Tweet
Share
Other Decks in Programming
See All in Programming
CSC509 Lecture 05
javiergs
PRO
0
300
CSC305 Lecture 05
javiergs
PRO
0
210
Go言語はstack overflowの夢を見るか?
logica0419
0
260
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
220
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
490
SpecKitでどこまでできる? コストはどれくらい?
leveragestech
0
740
Leading Effective Engineering Teams in the AI Era
addyosmani
3
340
TFLintカスタムプラグインで始める Terraformコード品質管理
bells17
2
160
Pull-Requestの内容を1クリックで動作確認可能にするワークフロー
natmark
2
510
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
130
uniqueパッケージの内部実装を支えるweak pointerの話
magavel
0
1k
10年もののAPIサーバーにおけるCI/CDの改善の奮闘
mbook
0
820
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
2.8k
How to Think Like a Performance Engineer
csswizardry
27
2k
The Language of Interfaces
destraynor
162
25k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Embracing the Ebb and Flow
colly
88
4.8k
A designer walks into a library…
pauljervisheath
209
24k
Leading Effective Engineering Teams in the AI Era
addyosmani
3
340
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
Why Our Code Smells
bkeepers
PRO
339
57k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.7k
Transcript
httpd.conf programming OSDC.tw 2013
@jeffhung • www.jeffhung.net/blog • Trend Micro Developer • Hadoop, Big
Data • and.. PaaS
PaaS?
Platform as a Service
Google AppEngine
TCloud, 2010
The Path to Pass into PasS Talk @ OSDC.tw 2011
Dispatcher MySQL& Database& MySQL& Database& MySQL& Database& MySQL& Database& Java&Web&
Container& Java&Web& Container& Java&Web& Container& Java&Web& Container& Hadoop& HBase& Hadoop& HBase& Hadoop& HBase& Hadoop& HBase& Lucene& Indexer& Lucene& Indexer& Lucene& Indexer& Search& Engine& Elaster&CAP&Service& (API&Server)& Elaster&CAP&Service& (API&Server)& Elaster&CAP&Service& (API&Server)& Elaster&CAP&Service& (API&Server)& api.elasterlabs.com.tw *.app.elasterlabs.com.tw Internet& Balancer Manage&
nginx
ZooKeeper
Lots of Java codes to implement the agents to control
nginx according to routing rules subscribed from ZK
Jserv: 㑌ཁሜҰ ࡞ۀܥ౷
lunastorm: 㑌ཁሜ Ұ message system
jeffhung: 㑌ཁሜҰ PaaS
20 RD + 6 months to built Elaster CAP
5 RD + 6 weeks to bootstrap a private PaaS
for our own
How?
We have a strong OPS team
do more with less don’t code anything
Apache HTTPd ++
Dispatcher done in httpd.conf
If it works, it works.
Bug? It’s apache’s fault
Redis replaces ZK
Apache replaces nginx
Glue together with httpd.conf
httpd.conf programming
function REDIS (cmd) { ... } # Call REDIS()?
# function REDIS (cmd) { ... } RewriteMap REDIS "prg:redis-cli
--raw" # Call REDIS()? ${REDIS:cmd}
if url == "/index.html" redirect "/404.html" else if proxy "/app/...",
"http://app/REDIS(app)"
# function REDIS (cmd) { ... } RewriteMap REDIS "prg:redis-cli
--raw" # if url == "/index.html" # redirect "/404.html" RewriteRule ^/index.html /404.html [L,P] # else if # proxy "/app/...", "http://app/REDIS(app)" RewriteRule ^([^\/]*)/(.*) ${REDIS:GET\ $1}/$2 [L,P]
Live Demo simplified https://github.com/jeffhung/osdc-2013-lightning
The Actual httpd.conf • Authentication & Authorization • Customer Header
Injection • Dispatching & Load Balancing
~200 lines of httpd.conf And several filter scripts
~200 lines of httpd.conf And several filter scripts dash2under.pl: #!/usr/bin/perl
$| = 1; # Turn off I/O buffering while (<STDIN>) { s/-/_/g; # Replace dashes with underscores print $_; }
If it works, it works.