Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 4 '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 4 '13 at 19:38
    
Oops... I meant on the fly, as in using mod_rewrite_html or whatever –  Foon Mar 5 '13 at 0:52
    
To possibly help clarify, could you provide an example of WHY you don't want it to prepended by /app –  Foon Mar 5 '13 at 3:35
    

1 Answer 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.

share|improve this answer
    
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 4 '13 at 19:31
    
nope cannot do that either, it's dynamic content :( –  jacktrades Mar 4 '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 4 '13 at 20:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.