0

I have a apache http server that acts as proxy to connect to backened app servers.

e.g. MachineA(https) -> MachineB(reverseproxy) -> MachineCn(App)

Here MachineA(Public_lb) port 9002 is mapped with MachineB(internal apache) port 7777.

In backened, I have different application servers running

for e.g.

  1. MachineC1 -> Weblogic
  2. MachineC2 -> Tomcat
  3. MachineC3 -> NodeJS
  4. MachineC4 -> Flask

Here there is single servername(MachineA: public_facing_lb) and port(9002). Here is my existing configuration in MachineB(apache reverseproxy server)looks like which works fine now for all weblogic connections. But when I add the proxy for other apps, it never works properly.

What I am doing wrong here ?

LoadModule weblogic_module   "/u01/oracle/ohssa/ohs/modules/mod_wl_ohs.so"

RewriteEngine On
    RewriteCond %{HTTPS} on
    RewriteRule ^$ http://%{HTTP_HOST} [L,R]



    <IfModule mod_weblogic.c>
       NameVirtualHost *:7777
      <VirtualHost *:7777>
        ServerName https://public_facing_lb:9002
        RewriteEngine       On
        RewriteOptions inherit
        RewriteRule ^/$ /pod/reactaphome [PT]
        Debug ALL
        MatchExpression /
        DebugConfigInfo ON
        WLLogFile /var/log/httpd/wlproxy-qa.log
        KeepAliveEnabled ON
        KeepAliveSecs  15
        WLProxySSLPassThrough ON
        ProxyPreserveHost On


     <Location /pod/reactapp1>
       ProxyPass  http://nodejssrv1:1337
       ProxyPassReverse  http://nodejssrv1:1337
     </Location>

     <Location /pod/flaskapp1>
       ProxyPass  http://flasksrv1:8080
       ProxyPassReverse  http://flasksrv1:8080
     </Location>

     <Location /pod/tomcatapp1>
       ProxyPass  http://tomcatsrv1:8080
       ProxyPassReverse  http://tomcatsrv1:8080
     </Location>

     <Location /pod/console>
        SetHandler weblogic-handler
        WebLogicHost wlssrv1
        WeblogicPort 7001
        WLSRequest On
        ProxyPass  http://wlssrv1:7001/console
        ProxyPassReverse http://wlssrv1:7001/console
     </Location>
        SetHandler weblogic-handler
        WebLogicHost wlssrv1
        WeblogicPort 7001
        ProxyPass /pod/wlsapp1 http://wlssrv1:7001/wlsapp1
        ProxyPassReverse /pod/wlsapp1 http://wlssrv1:7001/wlsapp1
        ProxyPass /pod/wlsapp2 http://wlssrv1:7001/wlsapp2
        ProxyPassReverse /pod/wlsapp2 http://wlssrv1:7001/wlsapp2
        ProxyPass /pod/wlsapp3 http://wlssrv1:7001/wlsapp3
        ProxyPassReverse /pod/wlsapp3 http://wlssrv1:7001/wlsapp3

        ProxyPass /wlsapphome/global http://wlssrv1:7001/resources/getGlobalAppsList
        ProxyPassReverse /wlsapphome/global http://wlssrv1:7001/resources/getGlobalAppsList
        ProxyPass /wlsapphome http://wlssrv1:7001/resources/getAppsList
        ProxyPassReverse /wlsapphome http://wlssrv1:7001/resources/getAppsList

     </VirtualHost>
    </IfModule> 

I might be doing mistake in putting the other app config inside the weblogic if module. If I am creating multiple virtual hosts, at any point of time only the first virtualhost works.

Do I need to load modules for tomcat, nodejs and flask to communicate, as the pages get loaded broken. Like mod_wl_ohs used for weblogic ?

kumarprd
  • 101
  • 4
  • When you say "doesn't work", what does that mean? What error do you get, what do the logs say? – Jenny D May 18 '18 at 19:06
  • @JennyD , I get no logs recorded in http, but it throws 502 bad gateway, with above config. If I remove the location directive of tomcat, flask & nodejs, then page opens for all web-logic connections. – kumarprd May 18 '18 at 19:24
  • @JennyD The broken pages get loaded with missing content. – kumarprd May 18 '18 at 20:05

1 Answers1

0

Your <Location> isn't properly closed, hence probably Apache is not even starting properly. Use </Location> to close.

For the "at any point of time only the first virtualhost works" problem, make sure that you specify:

 NameVirtualHost *:7777

before

 <VirtualHost *:7777>

And change the ServerName to be different in each virtual host (for example appname.example.com).

kubanczyk
  • 13,812
  • 5
  • 41
  • 55
  • The ServerName is the loadbalancer DNS name which is fixed – kumarprd May 18 '18 at 19:36
  • Thank you for pointing out the `` close mistake, It was a typing mistake in question. Actually after correcting it , it only loads the title of the page for nodejs application and never load the html page. – kumarprd May 18 '18 at 19:38
  • If I am changing the ServerName to different dns name like `appname.example.com` , then while accesing the url `https://https://public_facing_lb:9002/pod/appname` redirects to `http://appname.example.com:9002/appname` which never resolves. The LB is not in my control, so I cant do any hostfile changes in it. LB dns with 9002 is only mapped to apache hostname 7777. – kumarprd May 18 '18 at 19:50
  • In your specific case you must then stay with a singe VirtualHost clause. How does the nodejs page work if you put it through some other apache proxy? – kubanczyk May 18 '18 at 20:10
  • correct. Actually with my above config the nodejs, flask ui pages loaded but all broken and missing contents. – kumarprd May 18 '18 at 20:15
  • Well then take nodejs on a correct reverse proxy and start adding all the extra clauses until you see what is breaking it. The first hypothesis is that it gets broken by adding a `/pod/reactapp1` inside the url. – kubanczyk May 18 '18 at 20:20
  • nodejs actually loads only the title and ico file not the html page, which is weired, and log says:`[2018-05-18T20:17:17.2147+00:00] [OHS] [ERROR:32] [AH00898] [proxy] [client_id: 172.21.0.1] [host_id: 78b3c481f12c] [host_addr: 172.21.0.5] [pid: 192] [tid: 140291877037824] [user: oracle] [ecid: 005R82ZRksvFw0P6yfuXMG00002q000009] [rid: 0] [VirtualHost: public_lb:9002] AH00898: DNS lookup failure for: 172.21.0.9:1337img returned by /pod/img/node_logo.png, referer https://public_lb:9002/pod/reactapp1` . – kumarprd May 18 '18 at 20:24
  • If I am mapping the nodejs app port to to public_lb port direclty, the ui page loads without anything breaking. But here I have only one LB DNS and LB port, through which I have to expose all the applications. So using one http server in between. So I suspect may be any module is required , using which apache will talk to nodejs ?? – kumarprd May 18 '18 at 20:30