Sie sind auf Seite 1von 7

4/19/2015

ConfiguringanApachereverseproxyforconsumi...|SCN

GettingStarted Newsletters

LogOn

Hi,Guest

JoinUs

Store

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

Activity

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Browse

Communications

Actions

SAPGateway

ConfiguringanApachereverseproxyforconsuming
UI5/HTML5applications
PostedbyRanHassidinSAPGatewayonApr12,20135:08:20PM
Share

Tweet

Like

Hi,
InthisblogpostiwillshowhoweasilyyoucanconfigureareverseproxyinordertoconsumeUI5/HTML5gateway
basedapplications.
Inordertounderstandwhyweneedareverseproxywhenconsumingapi'sfromdifferentserverspleaserefertothe
followingarticle:
https://developer.mozilla.org/enUS/docs/HTTP/Access_control_CORS

So...Let'sgetstarted:

1.AMP(Apache,MySQLandPHP)

Firstlet'sdownloadtheAMPsoftwarebundlewhichreferstothefirstlettersofApache,MySQL,PHP.
EvenifyouarenotgoingtousePHPorMySQLitisrecommendedtodownloaditbecauseAMPalsocontainsavery
goodcontrolpanelwhichallowsyoutoeasilystart/stop/restartorchangetheconfigurationofeachoftheinstalled
packagesandwewillneeditinordertochangetheApacheconfigurations.
AMPpackageisavailableforallOS(Linux,MacOSXandWindows)butthisuserguidereferonlytoMACOSXand
Windows.

WindowsuserscaninstallWAMPbundle(whichrefertothefirstlettersofWindowsAMP)
MacOSXuserscaninstallMAMPbundle(whichrefertothefirstlettersofMacAMP)
LinuxuserscaninstallLAMP(notrelevantherebutgoodtoknow)
Windows/MACuserscanalsoinstalltheXAMPpackagewhichisthecrossplatformAMP

BecausewecanworkinacrossplatformenvironmentthisuserguideexampleswillbeontheXAMPpackage.
AllthescreencapturesofthisuserguidehavebeentakenontheWindowsenvironment.

DownloadXAMPPForWindowsfrom:http://www.apachefriends.org/en/xamppwindows.html
DownloadXAMPPForMacOsXfrom:http://www.apachefriends.org/en/xamppmacosx.html

OpenandinstallXAMPPonyourmachineandthansearchforXAMPPandclicktostartit.

AfteryoustartXAMPPyouwillseeunderthetaskbarthefollowingicon:

DoubleclickonthaticontoopenXAMPPControlpanelwhichlookslikethis:

http://scn.sap.com/community/gateway/blog/2013/04/12/configureapachereverseproxyforconsumingui5html5applications

1/7

4/19/2015

ConfiguringanApachereverseproxyforconsumi...|SCN

Usingthecontrolitsveryeasytogetthestatusonalloftheservices,start/stopservices,changeconfigurationandsee
logfiles.

2.ApacheConfiguration

InthisuserguideourfocuswillbeonlyontheApachewebserver.
OurApachewebserverwillactlikeareverseproxy.Weneedtoconfigurethereverseproxyinordertoavoid
CORS(asdescribedintheattachedarticle).
InordertodoitwewillneedtochangetheApachedefaultconfigurations.Theseconfigurationsaresavedina
filewiththenamehttpd.conf.Thereyoucanfinddifferentruleswhichapplyonthewebserverassoonasitstarted
(e.g.securityrules,ports,modulesandsoon).
Thehttpd.confisaregulartextfilewhichyoucaneditusingnotepad.Wheneditingthisfileandsaveityouwillneedto
restarttheApacheserverinordertoapplythosechanges.
UsingXAMPPcontrolpanelyoucaneasilychangetheconfigurationfilebyclickingontheConfigbuttonofthe
Apachelineandfromthedropmenuselectthe
firstoptionwhichis:Apache(httpd.conf)

AfterclickingonthatbuttonnotepadwillopenwiththeApacheconfigurations.
Youwillseetherealotoflinessopleasedon'tpanic
thosechangesandrestartthewebserver.

.Wewilldoonlyveryminorchangestothisfile,willsave

Thefile(atleastthebeginning)shouldlooklikethis:

It'sveryimportanttoknowthat#meansthatthisrowiscommentedsoalltherowswith#arenotexecutedwhenthe
webserverstartsonlytheoneswithout.

3.ChangingApacheConfiguration

Nowyouarereadytochangetheserverconfigurations.
PortasdefaultApacherunsonport80(whichisthedefaultportofHTTP).Sometimesthisportisblockedby
anotherservice(e.g.IIS,Tomcat),sometimesthefirewallblocksthisportduetosecurityreasonssotochange
thedefaultportjustpressonCTRL+Fandsearchforlisten.Thenyoushouldseethefollowing:

http://scn.sap.com/community/gateway/blog/2013/04/12/configureapachereverseproxyforconsumingui5html5applications

2/7

4/19/2015

ConfiguringanApachereverseproxyforconsumi...|SCN

Becauserowswith#arenotapplied,theonlyrowthatisrelevantisthelastone.Youcanchangeittoany
number...usuallyit's8000or8080butiitisrecommended8000because8080isthedefaultportofthe
Tomcatwebserver.
Afteryouchangeityoucantestitviathebrowserbynavigatingtohttp://localhost:{port_number}
Iftheportis80youcandropit,otherwiseitmustbespecifiedintheURL.
IfeverythingisOKyouwillbeautomaticallyredirectedtotheXAMPPhomepage(becausethesearetheXAMPP
defaultconfigurations).

ModulesInordertousethereverseproxywemustmakesurethatacoupleofmodulesareactive.Iftheyare
not,weneedtoactivatethemandrestarttheservertoapplythechanges.Inthedefaultsetupnotallthemodules
areactive.ThemoduleconfigurationscanbechangedthoughfromtheAMPversiontoanotherversion,sowe
needtomakesurebeforedefiningthereverseproxythatthemodulesweneedareactive.Inordertodoitopen
thehttpd.confandsearchforLoadModule.ThenyouwillseeseverallinesofLoadModulecommand.Againonly
thoselineswithout#areactive,soyoucanseethatpartofmodulesareactiveandpartofthemarenot.

Weneedtomakesurethatthefollowingmodulesareactiveandifoneofthemisnotactiveweneedtoactivateit
(bydeletingthe#atthebeginningoftherow):
LoadModuleproxy_modulemodules/mod_proxy.so
LoadModuleproxy_http_modulemodules/mod_proxy_http.so
LoadModulerewrite_modulemodules/mod_rewrite.so

ReverseProxyAfterdoingbothchangeswearereadytodefinethereverseproxy.Let'sscrolldowntowhere
alltheLoadModulecommandsend
andaddthefollowingrows:

ProxyPass/sap/http://{gateway_host}:{gateway_port}/sap/
ProxyPassReverse/sap/http://{gateway_host}:{gateway_port}/sap/

Explanation:Afterthatthosechangeswillapplyonthewebservereachtimethatyouwillnavigatetoyourweb
serverwiththefollowingURL:
http://{your_web_server_host}:{your_web_server_port}/sap/.....
ThewebserverwillautomaticallyredirectyouthetheGatewayserver(theonethatyouspecifiedafterthe
ProxyPass/ProxyPassReversecommands).
NowwhyareweavoidingCORSinthiscase?BecausewearenavigatingtoourownhostandtheUI5/HTML5
applicationishostedinourwebserversointhiswayweareavoidingCORS(crossdomains)issues.
It'sveryimportanttoknowthatifyouwanttheapplicationtowork,youmustspecifyyourmachinehostname
(wheretheXAMPPisinstalled)andnotusethelocalhostdomainbecauseifwewilluseitthedomainwill
bedifferentandwewillgettheCORSerror.Inordertoknowwhatisyourhostnamenavigateto:Start>Run
>cmdandintheshellwritehostnameandthenyouwillseethehostname.
NowjustcopyitandputitintheURLtogetherwiththeport.

4.Checkthateverythingisworking

http://scn.sap.com/community/gateway/blog/2013/04/12/configureapachereverseproxyforconsumingui5html5applications

3/7

4/19/2015

ConfiguringanApachereverseproxyforconsumi...|SCN

WedidsomechangestothedefaultconfigurationsofourApacheandnowit'stimetocheckthateverything
isworkingasexpected!
FirstrestarttheApachewebserverinordertoapplythechangesbyclickingonthestopbuttonandthenstart
again,makesurethatyouseeagreenbackgroundovertheApachetext

GotoStart>Run>cmdandgetyourmachinehostnamebyspecifyingthehostnamecommandintheshell
andcopythehostname
OpenthewebbrowserandspecifytheURL:http://{hostname}:
{port_number}/sap/opu/odata/iwfnd/CatalogService?$format=xml
IchoosetonavigatetotheCatalogServicewhichexistsonanyGatewayserverandactiveasdefault...butifyou
haveanotherserviceyoujustneedtoreplacethepathtobe
/sap/opu/odata/{service_namespace}/{service_name}?$format=xmlandclickonexecute.
IfeverythingisOK....ApachewillrecognizethattheURLcontains/sap/rightafterthehostandportandwill
automaticallyredirectyoutotheURLoftheGatewaythatwasspecifiedintheconfigurationfile.Onmymachine
forexampleigottheservicedocumentoftheCATALOGSERVICEserviceoftheGatewaythatispecifiedandit
lookslikethis:

Notice
InavigatedtomyhostnamebuttheresponsethatigotisanODATAservicedocumentfromgateway

That'sit.AfteryourreverseproxyisreadyyourcanstarttodevelopyourUI5applicationanddon'tforgettostorethe
applicationonyourApacheserver.
(insidethehtdocslibrary).Andwhenyouexecuterequeststogetdatayouwillusethe

http://{your_hostname}:{port}/sap/....URLinsideyourapplicationandbecauseyourapplicationishostedon
yourhostandyouaccessalsotoyourhostfromtheapplicationyouwillnotgetanyCORSerrors.

Hopethatyouenjoyedtoreadthisuserguideandifyouhaveanyquestionpleasedonothesitatetosendmean
emailto mailto:ran.hassid@sap.com

GoodLuck!
Ran.

7862Views

Products:sap_netweaver_gateway

AverageUserRating
(7ratings)

Share

Tweet

Like

http://scn.sap.com/community/gateway/blog/2013/04/12/configureapachereverseproxyforconsumingui5html5applications

4/7

4/19/2015

ConfiguringanApachereverseproxyforconsumi...|SCN

13Comments
CarlosDiasApr16,201312:59PM

HiRan,

I'mdevelopingapplicationswithSAPUI5andNetweaverGatewayand
yourpostwasveryuseful

Thanksalot
Like(2)

AntonyFERMINUSMay14,20138:56AM

HiRan,
Thanksforthegreatarticle.Itsolvedmyreverseproxyproblemtoo.
Ihaveonequestion.
WheniuseIEtheresultiscominginthetablenicely.ButinChromethedataiscommingbellowthe
table.
IsthatanissuewithSAPUI5?

Thanksinadvance.
Antony.
Like(0)

AntonyFERMINUSMay14,201312:05PM

HiRan,
Itisantonyagain.
Isolvedtheprobelem.Iforgottoremovetheportnumber.
Noweverythinisworkingfine.

Thanksforyourgreatblog.
Itsavedalotofmytimeandstress.

Regards,
Antony.
Like(1)

RanHassidMay20,20137:06AM(inresponsetoAntonyFERMINUS)

Iamveryhappytohearthat:).

goodluck!
Like(0)

UriNizanMay20,201312:47PM

HiRan,

Greatarticle.Thanks!
Like(1)

AndreFischerJul5,20135:52PM

HiRan,

averyusefulblog.

UsedittoconfiguretheportableversionofXAMPP.

http://www.apachefriends.org/en/xamppwindows.html#646

FirstIranintoerrorswhentryingtostartApache.Tryingtochangetheportnumbersdidnothelp...

OnlyafterreadingtheinstallationguideasecondtimeInoticedthatyoudonotonlyhavetounpack
thefilesbuthavetorunasetupscriptorusetheinstaller.(seebelow)

MethodB:"Installation"withouttheInstaller
Unziptheziparchivesintothefolderofyourchoice.XAMPPisextractingtothesubdirectory"
[Ziel]\xampp"belowtheselectedtargetdirectory.Nowstartthefile"setup_xampp.bat",toadjust
theXAMPPconfigurationtoyoursystem.
Ifyouchoosearootdirectory"C:\"astarget,youmustnotstart"setup_xampp.bat".
Likewiththeinstallerversion,youcannowusethe"XAMPPControlPanel"foradditionaltasks.
Like(1)

AntonioDelNegroJul15,201310:18AM

HiRan,

veryniceandusefulblog!Thankyouverymuch!

Regards,

Toni

http://scn.sap.com/community/gateway/blog/2013/04/12/configureapachereverseproxyforconsumingui5html5applications

5/7

4/19/2015

ConfiguringanApachereverseproxyforconsumi...|SCN
Like(1)

srinivassistuAug28,20136:23PM

Verynicearticle.CORSIbelievewas(is)mostsearchedtermafterSAPUI5cameintopicture....
Like(0)

RakeshKumarAug29,201312:24PM

HiRan,

Reallyappreciateyourworkhere...simpleandlucid,Forsomeonelikeme,whoisrelativelynewto
SAP,thesekindofworkonlyhelpsonetogetthroughthebasicconceptsinmanydifferentareasof
SAP.

Thanks,
Rakesh
Like(1)

OliverUnknownOct23,201412:32PM

HiRan,

isitpossibletogetaworkingexamplewithanApacheasReverseProxywhenthebackend(SAP
NetweaverApplicationServer)requiresClientCertificateAuthentication?

Icouldn'tgetittoworkbyforwardingtheClientCertintheHeaderbyusing

RequestHeadersetSSL_CLIENT_S_DN"%{SSL_CLIENT_S_DN}s"
RequestHeadersetSSL_CLIENT_I_DN"%{SSL_CLIENT_I_DN}s"
RequestHeadersetSSL_SERVER_S_DN_OU"%{SSL_SERVER_S_DN_OU}s"
RequestHeadersetSSL_CLIENT_VERIFY"%{SSL_CLIENT_VERIFY}s"

whichworkswellwhenthebackendalsoisanApache.

Thanks,
Oliver
Like(0)

SivaRamaKrushnaRDec26,20143:04PM

HelloRan,
MerryChristmas!!
Ifollowedyourarticle
ConfiguringanApachereverseproxyforconsumingUI5/HTML5applications.
Itwasverynice.Evennovicepeoplelikemecaneasilyunderstand.

Ihavedonereverseproxyasexplainedbyyou.
IamabletoruntheGWservicesuccessfullyinthewebservice.

Youmentionedbelowpoint
Don'tforgettostoretheapplicationonyourApacheserver.(insidethehtdocslibrary).
Canyoupleasetellmehowtodothis?

IskippedtheabovestepandtriedinTomcatserverthesame
IamusingTomcataswebserverinport8080andApacheinport8000
WhenIranintheapplicationinFirefoxbrowserinTomcatserver
http://<hostname>:8080/SearchOrders_gold/Igotthebelowerror.
CrossOriginRequestBlocked:TheSameOriginPolicydisallowsreadingtheremoteresourceat
http://<hostname>:8000/sap/opu/odata/sap/ZMOBILEORDERSEARCH_SRV/$metadata.Thiscanbe
fixedbymovingtheresourcetothesamedomainorenablingCORS.

Thanks,
Siva
Like(0)

RoshanJalgaonkarMar26,20156:59AM

HelloRan,

Thanksforsuchahelpfularticle.
Ihaveanquery,Iamgettingproperresponseformostofmygatewayservices,
butfor2ofserviceIamgettinganerrorsuchasObjectnotfound,TherequestedURLwasnotfound
onthisserver.IfyouenteredtheURLmanuallypleasecheckyourspellingandtryagain.
AndIamgettingthiserroronlywhenIamonxampserver.
WhenIexecutemyapplicationfromeclipseonlocalhost,itisexecutingfine.

Helpisappreciated

ThanksandRegards
RoshanJalgaonkar
Like(0)

http://scn.sap.com/community/gateway/blog/2013/04/12/configureapachereverseproxyforconsumingui5html5applications

6/7

4/19/2015

ConfiguringanApachereverseproxyforconsumi...|SCN
RanHassidMar30,20155:34AM(inresponsetoRoshanJalgaonkar)

HiRoshan,maybetheservicethatyouuseisnotexistornotactiveonthegatewaysystem?
Ran
Like(0)

SiteIndex
Privacy

ContactUs
TermsofUse

SAPHelpPortal
LegalDisclosure

Copyright

http://scn.sap.com/community/gateway/blog/2013/04/12/configureapachereverseproxyforconsumingui5html5applications

FollowSCN

7/7

Das könnte Ihnen auch gefallen