0

Having these two rules works good:

ProxyPass / http://localhost:8080/app
ProxyPassReverse / http://localhost:8080/app

When client visits, domain.com, Apache calls app server and it works as expected.

Problem is that there is one directory, generated by the app server that I don't want to be prepended with /app.

For example:

domain.com/app/styles/file.css (actual case)
domain.com/styles/files.css  (this is how I want this)

Any ideas?

jacktrades
  • 622
  • 3
  • 8
  • 17
  • I added answer, but it occurred to me ... is stuff in the app server linking to /app/styles/file.css or just /styles/file.css; the former may require rewriting the HTML on the file. – Foon Mar 04 '13 at 19:33
  • correct, first case, stuff in the app server. Can't rewrite it's coded on the app server, not in my code. – jacktrades Mar 04 '13 at 19:38
  • Oops... I meant on the fly, as in using mod_rewrite_html or whatever – Foon Mar 05 '13 at 00:52
  • To possibly help clarify, could you provide an example of WHY you don't want it to prepended by /app – Foon Mar 05 '13 at 03:35
  • @Foon http://stackoverflow.com/questions/15203177/apache-in-front-of-jsf – jacktrades Mar 05 '13 at 10:58

1 Answers1

-1

I'm still not 100% sure which way your issue is. If you want it so that when the browser sees something like

<link rel="stylesheet" href="/styles/main.css" type="text/css" />

It requests the main.css file that tomcat hosts at /app/styles/main.css

Try:

ProxyPass /styles http://localhost:8080/app/styles
ProxyPassReverse /styles http://localhost:8080/app/styles

ProxyPass / http://localhost:8080/app
ProxyPassReverse / http://localhost:8080/app

Conversely, if you want it so that when the browser sees something like

<link rel="stylesheet" href="/apps/styles/main.css" type="text/css" />

It gets the main.css file that tomcat hosts at /styles/main.css

Try:

ProxyPass /apps/styles http://localhost:8080/styles
ProxyPassReverse /apps/styles http://localhost:8080/styles

ProxyPass / http://localhost:8080/app
ProxyPassReverse / http://localhost:8080/app

In either case, Apache will match in the order stuff appears in the config file.

Foon
  • 103
  • 4
  • Also note that if stuff in /styles/ is all static files, you could move it into your httpd wwwroot (e.g. /var/www/html) and do something like: ProxyPass /styles ! to cause it to serve it from Apache httpd instead of tomcat or whatever your app server is. – Foon Mar 04 '13 at 19:31
  • nope cannot do that either, it's dynamic content :( – jacktrades Mar 04 '13 at 19:39
  • You might need to combine rewrite with ProxyPass, or use another context under /app/ to use with ProxyPass. – Akber Choudhry Mar 04 '13 at 20:32