SlideShare uma empresa Scribd logo
1 de 36
Baixar para ler offline
NGINX
THE WEB SERVER YOU MIGHT ACTUALLY LIKE
ABOUT ME
Software Engineer
PHP since 10 years
CI
CleanCode
DevOps
TDD
Shipping
Bullet points
INSTEAD OF ME
WORKING FOR




            gives science back to the people who make it happen.
We help researchers build reputation and accelerate scientific
                         progress.
                       On their terms.
LET'S GO
WHY ANOTHER WEBSERVER?
WHY NOT LIGHTTPD?
THE BASICS
Intro
Multiple Servers / Domains
Static content
Caching
SSL
Error pages
Rewrites
Auth
Load Balancing
Proxy
PHP!
Fancy PHP!
INTRO
sd atgtisalnix
 uo p-e ntl gn



/t/gn/gn.of
 ecnixnixcn
/t/gn/ofd*cn
 ecnixcn./.of
NGINX CONF BASICS
/t/gn/gn.of
 ecnixnixcn



ue nix
 sr gn;
wre_rcse 4
 okrpoess ;
wre_p_fiiy00 01 00 10;
 okrcuafnt 01 00 10 00

errlg /a/o/gn/ro.o wr;
 ro_o  vrlgnixerrlg an
pd
 i    /a/u/gn.i;
       vrrnnixpd

eet {
 vns
  wre_oncin
   okrcnetos 12;
              04
}
NGINX CONF BASICS
/t/gn/gn.of
 ecnixnixcn



ht {
 tp
   icue
    nld    /t/gn/ietps
            ecnixmm.ye;
   dfuttp apiainottsra;
    eal_ye plcto/ce-tem

    acs_o /a/o/gn/ceslg mi;
     ceslg vrlgnixacs.o an
    snfl
     edie    o;
              n
    keaietmot 6;
     eplv_ieu   5

    icue/t/gn/ofd*cn;
     nld ecnixcn./.of
}
SERVERS
/t/gn/ofdmSt.of
 ecnixcn./yiecn
/t/gn/ie-nbe/alah
 ecnixstsealdwlbs



sre {
 evr
  sre_aewlbs.o wlbs.e
   evrnm alahcm alahd;
  lse 8;
   itn 0
  ro /a/w/yp/tl
   ot vrwwmAphm/
  / ..
   / .
}

sre {
 evr
  sre_ae_
   evrnm ;
  lse 8;
   itn 0
  ro /a/w/yteAphm/
   ot vrwwmOhrp/tl
}
STATIC CONTENT
/t/gn/ofdayofgcn
 ecnixcn./nCni.of



sre {
 evr
  / ..
   / .

    lcto /{
     oain
    }
}
FANCY STATIC CONTENT
Isd Sre Bok
 nie evr lcs



lcto ~^/j|m|s|onod)/{
 oain  (sigcsdwlas
}



lcto ~(scspggfjgpf${
 oain  .j|s|n|i|p|d)
}
CACHING
lcto ~^/j|m|s)/{
 oain  (sigcs
  eprs1d
   xie 4;
}
DENY ACCESS TO ALL .DOT-FILES
Isd Sre Bok
 nie evr lcs



lcto ~/.{
 oain  
  acs_o of
   ceslg f;
  lgntfudof
   o_o_on f;
  dn al
   ey l;
}
SSL
sre {
 evr
  sre_ae_
   evrnm  ;
  lse 43
   itn 4;
  slo;
   s n
}


                      Or just
sre {
 evr
  lse 43dfutsre sl
   itn 4 eal_evr s;
}
SSL - CONFIG
slcriiae
 s_etfct     wlcr.r;
             idadct
slcriiaeky
 s_etfct_e   wlcr.e;
             idadky

slssintmot 5;
 s_eso_ieu  m
slssinccesae:S:0;
 s_eso_ah hrdSL1m

slpooosSL3TS1TS11TS12
 s_rtcl Sv Lv  Lv. Lv.;
slpee_evrcpeso;
 s_rfrsre_ihr  n
slcpesEDERAAS5-H34AS5-H26R4HG:M5!NL:EH!E
 s_ihr CH-S-E26SA8:E26SA5:C:IH!D:aUL!D:A
SC;
 GM
sled_uv sc511
 s_chcre ep2r;
ERROR PAGES
errpg 5051525354/0.tl
 ro_ae 0 0 0 0 0 50hm;

lcto /0.tl{
 oain 50hm
  itra;
   nenl
}



                 STARTUP BONUS:
sre {
 evr
  sre_ae*etiTigi;
   evrnm nxBghn.o

    lcto /0 {
     oain 50
       rtr 50
        eun 0;
    }
}
REWRITES
              HTTPS ALL THE THINGS
sre {
 evr
  sre_ae _
   evrnm   ;
  lse
   itn    8;
           0
  rwie^hts/$otrqetuipraet
   ert   tp:/hs$eus_r emnn;
}



                  OLDSCHOOL
rwie ^ues(+$ /hwue=1
 ert /sr/.)   so?sr$? ls;
                      at
AUTH
lcto /{
 oain
  at_ai "etitd;
   uhbsc Rsrce"
  at_ai_srfl /t/gn/ofdmAphpsw;
   uhbscue_ie ecnixcn./yp.tasd
}
LOAD BALANCING
usra wbwres{
 ptem e_okr
  sre ww.xml.o;
   evr w1eapecm
  sre ww.xml.o;
   evr w2eapecm
  sre ww.xml.o;
   evr w3eapecm
}
LOAD BALANCING LEGACY
usra wbwres{
 ptem e_okr
  i_ah
   phs;
  sre ww.xml.o;
   evr w1eapecm
  sre ww.xml.o;
   evr w2eapecm
  sre ww.xml.o;
   evr w3eapecm
}
PROXY
lcto /{
 oain
  poyps
   rx_as    ht:/oahs:00
            tp/lclot88;
  poysthae
   rx_e_edr XRa-P $eoead;
            -elI   rmt_dr
  poycce
   rx_ah    zn;
            oe

    /Dfut
     /eal:
    poycceky$ceepoyhs$r$sag$rs
     rx_ah_e shm$rx_otuii_rsag;
}
PHP!
PHP-FPM!?!
FastCGI Process Manager
PROCESS MANAGEMENT FOR THE MASSES
       Think: "supervisord"; But without caring

sd atgtisalpp-p
 uo p-e ntl h5fm

/t/h5fmppfmcn
 ecpp/p/h-p.of

/ Dntrsattewbevr rsatpp:
 / o' etr h esre, etr h )
sd sriepp-p rsat
 uo evc h5fm etr
FPM-CONFIG
[yp]
 mAp
lse =90
 itn 00
;itnalwdcins=17001
 lse.loe_let  2...

ue =pp
 sr  h
gop=pp
 ru   h

rqettriaetmot=1
 eus_emnt_ieu  0

rqetsolgtmot=1
 eus_lwo_ieu
solg=/a/o/h-p/yp-lwlg
 lwo  vrlgppfmmApso.o
FPM-CONFIG - PROCESS MANAGEMENT
p =dnmc
 m  yai
p.a_hlrn=5
 mmxcide  0
p.tr_evr =5
 msatsres
p.i_pr_evr =5
 mmnsaesres
p.a_pr_evr =3
 mmxsaesres  5
NGINX + PHP
lcto /{
 oain
  fscips
   atg_as   1700.:00
            2..1190;
  fsciidx
   atg_ne   idxpp
            ne.h;
  fsciprm
   atg_aa   SRP_IEAE$ouetro/ne.h;
            CITFLNM  dcmn_otidxpp
  icue
   nld      fsciprm;
            atg_aas
}
APPLICATION SERVERS!
lcto /{
 oain
  fscips
   atg_as   aoteSre:00
            nnhrevr90;
  fsciidx
   atg_ne   idxpp
            ne.h;
  fsciprm
   atg_aa   SRP_IEAE$ouetro/ne.h;
            CITFLNM  dcmn_otidxpp
  icue
   nld      fsciprm;
            atg_aas
}
SCALING!
lcto /{
 oain
  fscips
   atg_as   wres
            okr;
  fsciidx
   atg_ne   idxpp
            ne.h;
  fsciprm
   atg_aa   SRP_IEAE$ouetro/ne.h;
            CITFLNM  dcmn_otidxpp
  icue
   nld      fsciprm;
            atg_aas
}

usra wres{
 ptem okr
  sre
   evr Ap:00
        p190;
  sre
   evr Ap:00
        p290;
  sre
   evr 12181.:00
        9.6.0390;
}
THANKS HELGI!
@h

Further reading:
THANK YOU
Nginx & php fpm - the webserver you might actually like - php usergroup berlin

Mais conteúdo relacionado

Mais procurados (12)

Edit decision list
Edit decision listEdit decision list
Edit decision list
 
Plan del trabajo del departamento psicopedagógico
Plan del trabajo del departamento psicopedagógicoPlan del trabajo del departamento psicopedagógico
Plan del trabajo del departamento psicopedagógico
 
DJANGO-REST-FRAMEWORK: AWESOME WEB-BROWSABLE WEB APIS
DJANGO-REST-FRAMEWORK: AWESOME WEB-BROWSABLE WEB APISDJANGO-REST-FRAMEWORK: AWESOME WEB-BROWSABLE WEB APIS
DJANGO-REST-FRAMEWORK: AWESOME WEB-BROWSABLE WEB APIS
 
Retur
ReturRetur
Retur
 
ICDL CORE CERTIFICATE
ICDL CORE CERTIFICATEICDL CORE CERTIFICATE
ICDL CORE CERTIFICATE
 
2011_TU_SOFIQ_MAGISTAR_ELMS_DIPLOMA
2011_TU_SOFIQ_MAGISTAR_ELMS_DIPLOMA2011_TU_SOFIQ_MAGISTAR_ELMS_DIPLOMA
2011_TU_SOFIQ_MAGISTAR_ELMS_DIPLOMA
 
Img 0012
Img 0012Img 0012
Img 0012
 
CHSEP Certificate
CHSEP CertificateCHSEP Certificate
CHSEP Certificate
 
Professional Certificate in Facilities Management Series II
Professional Certificate in Facilities Management Series IIProfessional Certificate in Facilities Management Series II
Professional Certificate in Facilities Management Series II
 
Shorter Transcipt Pg 1
Shorter Transcipt Pg 1Shorter Transcipt Pg 1
Shorter Transcipt Pg 1
 
modelo organizaciónal 2
modelo organizaciónal 2modelo organizaciónal 2
modelo organizaciónal 2
 
1999_2004_TU_BAKALAVAR_EL_ENG_DIPLOMA
1999_2004_TU_BAKALAVAR_EL_ENG_DIPLOMA1999_2004_TU_BAKALAVAR_EL_ENG_DIPLOMA
1999_2004_TU_BAKALAVAR_EL_ENG_DIPLOMA
 

Destaque

High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
vnsavage
 
National Geographic2
National Geographic2National Geographic2
National Geographic2
guest707d8f1
 
2118 Final With Bg 2
2118 Final With Bg 22118 Final With Bg 2
2118 Final With Bg 2
2118tibet
 

Destaque (20)

High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
PHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on NginxPHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on Nginx
 
AWS Cloudfront Howto
AWS Cloudfront HowtoAWS Cloudfront Howto
AWS Cloudfront Howto
 
Server side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHPServer side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHP
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLI
 
WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)
 
What to look for in a hosted supplier
What to look for in a hosted supplierWhat to look for in a hosted supplier
What to look for in a hosted supplier
 
National Geographic2
National Geographic2National Geographic2
National Geographic2
 
Moodle - add topic to course page
Moodle - add topic to course pageMoodle - add topic to course page
Moodle - add topic to course page
 
From dev to ops and beyond - getting it done
From dev to ops and beyond - getting it doneFrom dev to ops and beyond - getting it done
From dev to ops and beyond - getting it done
 
Restorative practices at rahs -update board
Restorative practices at rahs -update boardRestorative practices at rahs -update board
Restorative practices at rahs -update board
 
Field Studies Council anticipates savings of up to £100,000 per annum with do...
Field Studies Council anticipates savings of up to £100,000 per annum with do...Field Studies Council anticipates savings of up to £100,000 per annum with do...
Field Studies Council anticipates savings of up to £100,000 per annum with do...
 
Mit pune e prospectus
Mit pune e prospectusMit pune e prospectus
Mit pune e prospectus
 
2118 Final With Bg 2
2118 Final With Bg 22118 Final With Bg 2
2118 Final With Bg 2
 
Naomi bills
Naomi billsNaomi bills
Naomi bills
 
כלי להערכת ההוראה באמצעות וידאו
כלי להערכת ההוראה באמצעות וידאוכלי להערכת ההוראה באמצעות וידאו
כלי להערכת ההוראה באמצעות וידאו
 
Edc Leap Social Media
Edc Leap Social MediaEdc Leap Social Media
Edc Leap Social Media
 
Implementing and using employee self-service software
Implementing and using employee self-service softwareImplementing and using employee self-service software
Implementing and using employee self-service software
 
MANO
MANOMANO
MANO
 
php unconference Europa: Clean code - Stop wasting my time
php unconference Europa: Clean code - Stop wasting my timephp unconference Europa: Clean code - Stop wasting my time
php unconference Europa: Clean code - Stop wasting my time
 

Mais de Edorian (11)

Your (coding) standards matter
Your (coding) standards matterYour (coding) standards matter
Your (coding) standards matter
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
 
Nginx - The webserver you might actually like
Nginx - The webserver you might actually likeNginx - The webserver you might actually like
Nginx - The webserver you might actually like
 
Code review in practice
Code review in practiceCode review in practice
Code review in practice
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
 
Clean code is not the goal - working software is
Clean code is not the goal - working software isClean code is not the goal - working software is
Clean code is not the goal - working software is
 
The state of PHPUnit
The state of PHPUnitThe state of PHPUnit
The state of PHPUnit
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
Stop wasting-time-by-applying-clean-code-principles
Stop wasting-time-by-applying-clean-code-principlesStop wasting-time-by-applying-clean-code-principles
Stop wasting-time-by-applying-clean-code-principles
 
Clean Code: Stop wasting my time
Clean Code: Stop wasting my timeClean Code: Stop wasting my time
Clean Code: Stop wasting my time
 

Nginx & php fpm - the webserver you might actually like - php usergroup berlin

  • 1. NGINX THE WEB SERVER YOU MIGHT ACTUALLY LIKE
  • 2. ABOUT ME Software Engineer PHP since 10 years CI CleanCode DevOps TDD Shipping Bullet points
  • 4.
  • 5. WORKING FOR gives science back to the people who make it happen. We help researchers build reputation and accelerate scientific progress. On their terms.
  • 9. THE BASICS Intro Multiple Servers / Domains Static content Caching SSL Error pages Rewrites Auth Load Balancing Proxy PHP! Fancy PHP!
  • 10. INTRO sd atgtisalnix uo p-e ntl gn /t/gn/gn.of ecnixnixcn /t/gn/ofd*cn ecnixcn./.of
  • 11. NGINX CONF BASICS /t/gn/gn.of ecnixnixcn ue nix sr gn; wre_rcse 4 okrpoess ; wre_p_fiiy00 01 00 10; okrcuafnt 01 00 10 00 errlg /a/o/gn/ro.o wr; ro_o vrlgnixerrlg an pd i /a/u/gn.i; vrrnnixpd eet { vns wre_oncin okrcnetos 12; 04 }
  • 12. NGINX CONF BASICS /t/gn/gn.of ecnixnixcn ht { tp icue nld /t/gn/ietps ecnixmm.ye; dfuttp apiainottsra; eal_ye plcto/ce-tem acs_o /a/o/gn/ceslg mi; ceslg vrlgnixacs.o an snfl edie o; n keaietmot 6; eplv_ieu 5 icue/t/gn/ofd*cn; nld ecnixcn./.of }
  • 13. SERVERS /t/gn/ofdmSt.of ecnixcn./yiecn /t/gn/ie-nbe/alah ecnixstsealdwlbs sre { evr sre_aewlbs.o wlbs.e evrnm alahcm alahd; lse 8; itn 0 ro /a/w/yp/tl ot vrwwmAphm/ / .. / . } sre { evr sre_ae_ evrnm ; lse 8; itn 0 ro /a/w/yteAphm/ ot vrwwmOhrp/tl }
  • 14. STATIC CONTENT /t/gn/ofdayofgcn ecnixcn./nCni.of sre { evr / .. / . lcto /{ oain } }
  • 15. FANCY STATIC CONTENT Isd Sre Bok nie evr lcs lcto ~^/j|m|s|onod)/{ oain (sigcsdwlas } lcto ~(scspggfjgpf${ oain .j|s|n|i|p|d) }
  • 16. CACHING lcto ~^/j|m|s)/{ oain (sigcs eprs1d xie 4; }
  • 17. DENY ACCESS TO ALL .DOT-FILES Isd Sre Bok nie evr lcs lcto ~/.{ oain acs_o of ceslg f; lgntfudof o_o_on f; dn al ey l; }
  • 18. SSL sre { evr sre_ae_ evrnm ; lse 43 itn 4; slo; s n } Or just sre { evr lse 43dfutsre sl itn 4 eal_evr s; }
  • 19. SSL - CONFIG slcriiae s_etfct wlcr.r; idadct slcriiaeky s_etfct_e wlcr.e; idadky slssintmot 5; s_eso_ieu m slssinccesae:S:0; s_eso_ah hrdSL1m slpooosSL3TS1TS11TS12 s_rtcl Sv Lv Lv. Lv.; slpee_evrcpeso; s_rfrsre_ihr n slcpesEDERAAS5-H34AS5-H26R4HG:M5!NL:EH!E s_ihr CH-S-E26SA8:E26SA5:C:IH!D:aUL!D:A SC; GM sled_uv sc511 s_chcre ep2r;
  • 20. ERROR PAGES errpg 5051525354/0.tl ro_ae 0 0 0 0 0 50hm; lcto /0.tl{ oain 50hm itra; nenl } STARTUP BONUS: sre { evr sre_ae*etiTigi; evrnm nxBghn.o lcto /0 { oain 50 rtr 50 eun 0; } }
  • 21. REWRITES HTTPS ALL THE THINGS sre { evr sre_ae _ evrnm ; lse itn 8; 0 rwie^hts/$otrqetuipraet ert tp:/hs$eus_r emnn; } OLDSCHOOL rwie ^ues(+$ /hwue=1 ert /sr/.) so?sr$? ls; at
  • 22. AUTH lcto /{ oain at_ai "etitd; uhbsc Rsrce" at_ai_srfl /t/gn/ofdmAphpsw; uhbscue_ie ecnixcn./yp.tasd }
  • 23. LOAD BALANCING usra wbwres{ ptem e_okr sre ww.xml.o; evr w1eapecm sre ww.xml.o; evr w2eapecm sre ww.xml.o; evr w3eapecm }
  • 24. LOAD BALANCING LEGACY usra wbwres{ ptem e_okr i_ah phs; sre ww.xml.o; evr w1eapecm sre ww.xml.o; evr w2eapecm sre ww.xml.o; evr w3eapecm }
  • 25. PROXY lcto /{ oain poyps rx_as ht:/oahs:00 tp/lclot88; poysthae rx_e_edr XRa-P $eoead; -elI rmt_dr poycce rx_ah zn; oe /Dfut /eal: poycceky$ceepoyhs$r$sag$rs rx_ah_e shm$rx_otuii_rsag; }
  • 26. PHP!
  • 28. PROCESS MANAGEMENT FOR THE MASSES Think: "supervisord"; But without caring sd atgtisalpp-p uo p-e ntl h5fm /t/h5fmppfmcn ecpp/p/h-p.of / Dntrsattewbevr rsatpp: / o' etr h esre, etr h ) sd sriepp-p rsat uo evc h5fm etr
  • 29. FPM-CONFIG [yp] mAp lse =90 itn 00 ;itnalwdcins=17001 lse.loe_let 2... ue =pp sr h gop=pp ru h rqettriaetmot=1 eus_emnt_ieu 0 rqetsolgtmot=1 eus_lwo_ieu solg=/a/o/h-p/yp-lwlg lwo vrlgppfmmApso.o
  • 30. FPM-CONFIG - PROCESS MANAGEMENT p =dnmc m yai p.a_hlrn=5 mmxcide 0 p.tr_evr =5 msatsres p.i_pr_evr =5 mmnsaesres p.a_pr_evr =3 mmxsaesres 5
  • 31. NGINX + PHP lcto /{ oain fscips atg_as 1700.:00 2..1190; fsciidx atg_ne idxpp ne.h; fsciprm atg_aa SRP_IEAE$ouetro/ne.h; CITFLNM dcmn_otidxpp icue nld fsciprm; atg_aas }
  • 32. APPLICATION SERVERS! lcto /{ oain fscips atg_as aoteSre:00 nnhrevr90; fsciidx atg_ne idxpp ne.h; fsciprm atg_aa SRP_IEAE$ouetro/ne.h; CITFLNM dcmn_otidxpp icue nld fsciprm; atg_aas }
  • 33. SCALING! lcto /{ oain fscips atg_as wres okr; fsciidx atg_ne idxpp ne.h; fsciprm atg_aa SRP_IEAE$ouetro/ne.h; CITFLNM dcmn_otidxpp icue nld fsciprm; atg_aas } usra wres{ ptem okr sre evr Ap:00 p190; sre evr Ap:00 p290; sre evr 12181.:00 9.6.0390; }