logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: reverse proxy duplicates path for browsers only
Author
chembrothers2000



Joined: 07 Aug 2018
Posts: 3
Location: washington dc

PostPosted: Tue 07 Aug '18 21:31    Post subject: reverse proxy duplicates path for browsers only Reply with quote

Bit of a noob with Apache in general so bear with me. Trying to setup a reverse proxy for a web app which I've figured out in the past with other servers.

With my current proxypass setup when I curl the machine it succeeds with http200 and I get the webpage back. enabling debug for apache I can see that when the browser makes a request, it appends a path twice. it does not do this via curl however.


Code:

$ curl --location -v webserver01.foo.com
* About to connect() to webserver01.foo.com port 443 (#0)
* Connected to webserver01.foo.com (192.168.1.101) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: webserver01.foo.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 03 Aug 2018 16:32:05 GMT
< Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips
< X-ORACLE-DMS-ECID: 4d5f1f8c-a7a8-497e-94a4-aafae5d174ae-000005c0
< X-ORACLE-DMS-RID: 0
<
<!DOCTYPE html>
<html class="" lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="refresh" content="0; url=htp/sa_owa_menu">
    <title>WebApp01</title>
  </head>
</html>


apache error_log snip from curl

Code:

[Tue Aug 07 15:03:04.693674 2018] [proxy:debug] [pid 7793] proxy_util.c(2256): [client 192.168.1.123:56422] AH00944: connecting http://localhost:8084/spider_web_app/ to localhost:8084
[Tue Aug 07 15:03:04.693682 2018] [proxy:debug] [pid 7793] proxy_util.c(2426): [client 192.168.1.123:56422] AH00947: connected /spider_web_app/ to localhost:8084


When trying to hit the apache servername via firefox/internet explorer it will return a 404 from the backend server. the error log tries to double the path, which i think is my issue; "spider_web_app" gets duped when the browser makes the request, versus the curl command it does not. I would think the behavior for curl would be similar as browser for a request like this.

Code:

```
[Tue Aug 07 15:05:26.107082 2018] [proxy_http:trace1] [pid 7750] mod_proxy_http.c(60): [client 192.168.1.124:54662] HTTP: canonicalising URL //localhost:8084/spider_web_app/spider_web_app/auth/weblogic.init, referer: http://webserver01.foo.com/htp/sa_owa_menu
[Tue Aug 07 15:05:26.107116 2018] [proxy:trace2] [pid 7750] proxy_util.c(1985): [client 192.168.1.124:54662] http: found worker http://localhost:8084/spider_web_app/ for http://localhost:8084/spider_web_app/spider_web_app/auth/weblogic.init, referer: http://webserver01.foo.com/htp/sa_owa_menu


apache config; testing http and https gets same results, https works via curl as well

Code:

LoadModule weblogic_module /etc/httpd/plugins/Plugin12c/lib/mod_wl_24.so
LogLevel debug trace8

<VirtualHost *:80>
  ServerName webserver01.foo.com
#  ProxyPreserveHost On
  ProxyPass "/" "http://localhost:8084/spider_web_app/"
  ProxyPassReverse "/" "http://localhost:8084/spider_web_app/"
</VirtualHost>

<IfModule mod_weblogic.c>
  WebLogicHost localhost
  WeblogicPort 8084
  # PathTrim /spider_web_app
</IfModule>

<Location />
  SetHandler weblogic-handler
  # WLSRequest On
</Location>


Being a bit new to this guessing I may be overlooking something simple with my proxypass setup since the curl command does work ok. I did try a nocanon directive for proxypass to see if it would not "canonicalise" the URL but it still does the same. Any pointers to the double path issue?

summary:
- RHEL 7.5 with Apache 2.4.6
- curl apache servername returns fine
- hit apache servername with IE/firefox ends up double appending in path causing 404
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Wed 08 Aug '18 9:03    Post subject: Reply with quote

It often causes trouble when there is a path on one part of the proxy and not on the other one.

You may try

Code:

<VirtualHost *:80>
    ServerName webserver01.foo.com
    <Location "/spider_web_app/">
        ProxyPass "http://localhost:8084/spider_web_app/"
        ProxyPassReverse "http://localhost:8084/spider_web_app/"
    </Location>
</VirtualHost>
Back to top
chembrothers2000



Joined: 07 Aug 2018
Posts: 3
Location: washington dc

PostPosted: Wed 08 Aug '18 22:36    Post subject: Reply with quote

Ah, I see.

I've been playing with this, i think i need to make it simply

Code:
<Location "/">


Otherwise cannot just hit the root servername and get the right page back.

Curl still works fine but the browser does not...

Playing with this more, i can get the browser to function if do the code like such and manually go to full path like: http://webserver01.foo.com/spider_web_app

Code:

<VirtualHost *:80>
    ServerName webserver01.foo.com
    <Location "/spider_web_app/">
        ProxyPass "http://localhost:8084/"
        ProxyPassReverse "http://localhost:8084/"
    </Location>
</VirtualHost>


But trying various combinations to simply get the / root webserver01.foo.com to go to the path fail. Perhaps I need some redirect magic to get it working.

End goal would be user just types in http(s)://webserver01.foo.com and site comes up. Don't have to hide the spider_web_app path even.
Back to top
chembrothers2000



Joined: 07 Aug 2018
Posts: 3
Location: washington dc

PostPosted: Wed 15 Aug '18 3:35    Post subject: Reply with quote

In case this is helpful for anyone else, got this mostly working now. Will need to add some additional location paths most likely, to resolve however the developers did their apps with the custom context paths on the weblogic side. Or i need to learn to do some more magic on the apache side.

Also may need to mess with java keystores for any java applets that launch I think.

Code:

<VirtualHost *:80>
  ServerName webserver01.foo.com
  RedirectMatch Permanent / https://webserver01.foo.com/spider_web_app/$1
</VirtualHost>

<VirtualHost *:443>
  ServerName webserver01.foo.com
  SSLEngine On
  SSLCertificateKeyFile "/etc/pki/tls/private/webserver01.foo.com.key"
  SSLCertificateFile    "/etc/pki/tls/certs/webserver01.foo.com.cer"
  RedirectMatch Permanent / https://webserver01.foo.com/spider_web_app/$1
  <Location "/spider_web_app/">
    ProxyPreserveHost On
    ProxyPass "http://localhost:8084/spider_web_app/"
    ProxyPassReverse "http://localhost:8084/spider_web_app/"
    RequestHeader set WL-Proxy-SSL true
  </Location>
</VirtualHost>


## Load this module for oracle plugin
LoadModule weblogic_module /etc/httpd/plugins/Plugin12c/lib/mod_wl_24.so

<IfModule mod_weblogic.c>
  SetHandler weblogic-handler
  WebLogicHost localhost
  WeblogicPort 8084
</IfModule>
Back to top


Reply to topic   Topic: reverse proxy duplicates path for browsers only View previous topic :: View next topic
Post new topic   Forum Index -> Apache