providing http service on a port - candela …€¦providing http service on a port goal: configure...
TRANSCRIPT
http://[email protected]+13603801618[PST,GMT-8]
ProvidingHTTPServiceonaPort
Goal:ConfigureandactivateahttpserverboundtoaspecificportinLANforge.
Thisisusefulifyouwanttoprovideanapplicationlayertargettointeractwith.ThiscookbookassumesyoucanaccessashellpromptontheLANforgecomputer:thecommand-lineinstructionscanbedoneatthesystemconsole,inaterminaloveraremotedesktopconnection,oroverssh.ThenginxserviceisonlyavailableontheLinuxversionofLANforgeserver.
Note:TherearetwowebserversinstalledinaLANforgecomputer.ThedefaultwebserverisastockversionofApacheHTTPDthatrespondstoallport80requestsonallinterfaces.FortestingwerecommendrunningCandelaTechnologies'versionofNginxonspecificportsascoveredinthiscookbook.Incontrast,Apachecannotbindtoanetwork-devicethereforewedonotsuggestrunningit.
NginxcanalsobeconfiguredtolistentoIPv6traffic.Jumptotheendofthecookbookforthattechnique.
1. StopanddisableLANforgesystemApacheinstance.A. LogintotheLANforgecomputerasuserlanforge
NetworkTestingandEmulationSolutions
B. Becomesuper-userusingthecommandsu-(orsudo-s)
C. StoptheApacheservicewithsystemctlstophttpd
D. Ifyouwantthissettingtopersistafterareboot,disabletheservice:systemctldisablehttpd
E. Setthisassystemdefaultwith:systemctldaemon-reload
2. (Optional)ThereareotheroptionsforrunningApacheifyouwanttohavebothwebserversavailable.YouwouldnotneedstopanddisableApache,justrestartit.YoucanchangeApacheto:
A. ...listentoadifferentport(like81).Edit/etc/httpd/conf/httpd.confandchangetheListenoption.
B. ...bindtoaspecificIPaddress,whichisagoodoptionifyouconfiguretheLANforgecomputertohaveafixedIPaddressonthemanagementport.Youwouldedithttpd.confandchangeListentothatspecificIPaddressandport80.Example:Listen192.168.1.40:80
3. Thedemonstrationtestwe'llcreateismakingtwoports,oneformakingrequestsandtheotheroneforservingtheprotocol.Let'screatetwoports:
A. Createaredirectdevice:A. InthePortstab,clicktheCreatebutton
B. SelectRedirect
C. Enterrd0afor#1Redirname,D. andrd0bfor#2Redirname.E.ClickApplyandthenCanceltoclosethewindow.
B. Configurerd0aastheserviceport:
A. InthePortstab,double-clicktherowforportrd0a
B. TheConfigureSettingswindowwillappear
C. SetanIPof10.2.0.1,D. anetmaskof255.255.255.0E. andthereporttimetofaster(1s).
F. ClickOK
C. Configurerd0basaclientportA. InthePortstab,double-clicktherowforportrd0b
B. TheConfigureSettingswindowwillappear
C. SetanIPof10.2.0.3,D. anetmaskof255.255.255.0E. andthereporttimetofaster(1s).
F. ClickOK
4. EnableHTTPserviceonyourupstreamportusingthefollowingsteps.
A. Enablethenginxserviceonportrd0a:A. InthePortstab,double-clicktherowforportrd0a
B. TheConfigureSettingswindowwillappear
C. Inthelowerleftcolumnofthewindow,enableHTTPoption.
D. ClickOKandthenclosethewindow.
B. (Optional)Modifythenginxconfigfileforportrd0a.ThisexampleassumesyouareloggedintotheLANforgesystemconsole,orhaveconnectedtothedesktopusingaremote-desktopclientlikevncviewer.Ifyouarefamiliarwitheditingfromthecommand-line,youwilllikelyknowhowtodothisviassh.
A. FromthedesktopAccessoriesmenu,selectTerminalEmulator,
B.ChangetotheLANforgenginxdirectory:cd/home/lanforge/vr_conf
C. Editthefilenginx_rd0a.conf.Ifyoudonotseethefile,youmighthaveconnectedtothewrongLANforgeresource,oryoumightnothaveclickedOK/ApplywhenenablingtheConfigureSettingswindowforportrd0a.
D. Youwillseethatthelistendirectiveisalreadysetto10.2.0.1:80bind_dev=rd0a;
E. Ifyouwanttochangesettings,deletethefirstlineoftheconfigfileaspartofyourchanges.ThiswillsignalLANforgenottooverwritethefile.
C. Toapplythechangestothenginxserviceonthisport:A. DisabletheHTTPDserviceintherd0aConfigureSettingswindow,
B.ClicktheApplybutton,C. EnableHTTPDservice,
D. ClicktheApplybutton,
E.ClicktheCancelbuttontoclosethewindowifyouaredone.
D. Aquickwaytoaddafileintothenginxdocumentrootfolderistosymlinkthesystemdictionarythere.Youwillneedtobeinaterminalorunixshelloftheresourcerunningnginx(192.168.100.40inthisexample)
A. Changetheownershipofthedocumentrootdirectorytouserlanforge:B. sudochownlanforge:lanforge/usr/local/lanforge/nginx/html
C. cd/usr/local/lanforge/nginx/html
D. ln-s/usr/share/dict/linux.words.
E. (Optional)Toloadalargerpayload(suchasaDVDfile),youcanuseFilezilla(orscp)tocopythefileover.Youwillwanttohavechangedthenginxdocumentrootdirectoryownertolanforge(asabove):
A. Fromyourdesktop,usingFilezilla
I. quickconnecttosftp://192.168.100.40(alsonamedjed-f20inthisexample)
II. usingusernamelanforgeandpasswordlanforge
E. youwillseethefilewhenitistransferredappearintherightcolumn
5. Configureapplication-layertrafficusingtheLayer-4tabtools:A. IntheLayer-4tab,clicktheCreatebutton,
B. YouwillseetheCreate/ModifyL4Endpointwindow
C. Createaconnectionnamedweb-requests,
D. WithaReporttimeroffast(1s)
E. fromResource(jed-f20)portrd0b.
F. Let'smaketenrequestsasecond.Enter6000forURLsper10m.
G. JumpdowntotheURLfield,andenterhttp://10.2.0.1/index.html
H. andtoavoidsavingtheresult,settheDestFileto/dev/null
I. ClickOKandthewindowwillclose.
6. Runningthetrafficissimple:A. Selecttherownamedweb-requestsintheLayer-4table,
B. ClicktheStartbutton.
C. ClicktheDisplaybuttontoseemoredetailonthetraffic:
7. Itisalsopossibletoverifyyourconnectionsetupfromthecommand-line:
A. ToverifytheLayer3connection,youcanuseping:ping-I10.2.0.310.2.0.1
B. Toseethatnginxislisteningonport80,usenetstatontheresourcerunningnginxandseewhatislisteningonport80:sudonetstat-ntlp|grep':80'
C. Toseetheoutputofthewebrequest,youcanuseLANforge'sversionofcurllocatedin/home/lanforge/local/bin/curl.Sinceitusesbundledlibraries,firsttype:cd/home/lanforge&&../lanforge.profileThissetsupallenvironmentvariablesandpathstoworkwiththebinariesandlibrariesshippedwithLANforge.
D. Verifyitrunswithoutcomplaint:/home/lanforge/local/bin/curl--help
E. Ifyouscrollupinyourterminal,youwillseeoptionsavailableintheoutputnotfoundinanormalversionofcurl,like--dns_server,--dns_interface,--dns_ip4_addr,--dns_ip6_addr,--interfaceand--localaddr.Wewilluse--interfacenext.
F. Craftyourdownloadcommand:cd/home/lanforge/local/bin./curl--interface10.2.0.3'http://10.2.0.1/index.html'
G. Youwillseethehtmloutputintheterminal:
H. Therewillbearecordofconnectionsanderrorsinthenginxlogsdirectory:cd/usr/local/lanforge/nginx/logs
8. [Advanced]CreatingIPv6traffictonginx.Wewillassumeascenariowhereeth1willservenginxrequestsandeth2willgeneraterequests.
A. AddIPv6addressestoyourports.Wewilladdee::2:1/120foreth1,ee::2:2/120foreth2,andsetthegatewaysforthemtoee::2:fe.Wewon'tactuallyuseagateway,butourportconfigurationrequiresit.
A. Hereiseth1,andwewillenabletheHTTPserviceaswell.
B.Hereiseth2,noticehowweaddedanIPv4addresstotheport.DothatsothattheCreateLayer-4dialogdoesnotcomplain.
C. HereisapictureofthePortMgrtab,withportsontworesourcesconfigured.
D. Verifyyourconnectionbetweenportsusingping6:$ping6-Iee::2:2%eth2ee::2:1
B. Edityour/home/lanforge/vr_conf/nginx_eth1.conffile.YouwillremovetheheadercommentandalterthelistenstatementstoincludeIPv6addresses.Youcanlistenfor[::]oryoucouldlistenfor[ee::2:1]
C. IfyouprovideanIPv6address,pleasewatchthenginxlogfileforerrors:listeningonanIPv6addressiseasytomisconfigure.Thelogfilescanbefoundin/usr/local/lanforge/nginx/logs
D. Re-startthehttpserviceoneth1byun-checkingHTTP,clickingApply,checkingHTTP,clickingOK.
E. ConfigureyourLayer-4endpoint:
A. Nameyourendpoint
B. SetyourURLsperMinute
C. SpecifytheURLwithbrackesaroundtheaddress:http://[ee::2:1]/index.htmlD. Setyouroutputfileto/dev/null
F. Youcanwatchtrafficoneth1oreth2toverifythewebrequests.
CandelaTechnologies,Inc.,2417MainStreet,Suite201,Ferndale,WA98248,USAwww.candelatech.com|[email protected]|+1.360.380.1618