I'm gussing that http://example.com/styles/4742a4e8.main.css
is actually a file on your node JS application, so refers to http://localhost:8080/styles/4742a4e8.main.css
, but is being reference in the index.html from your node app as /styles/4742a4e8.main.css
With the proxy mapping what is happening is that when you request
http://example.foo/foo/
it's sending a request which is returning http://localhost:8080/index.html
as is. Any references within index.html aren't modified, so when the browser requests componenets it's requesting http://example.com/styles/4742a4e8.main.css
but the file is only really accessible via http://example.com/foo/styles/4742a4e8.main.css
if /styles/ isn't used within example.com you could add
ProxyPass /styles http://localhost:8080/styles
ProxypassReverse /styles http://localhost:8080/styles
But this may become cumbersome if you have lots of directories.
Another approach would be to use relative paths on your node app. So instead of index.html referencing /styles/4742a4e8.main.css
it referenced styles/4742a4e8.main.css
(no leading slash). This might become cumbersome with nested paths in your node app.
A further solution may be to modify your node.js app to be fully run under localhost:/foo so the directory mapping is the same.
I'm not sure any of these solutions are ideal for your use case, but they will hopefully point you in the right direction.
It made me suspicious that I got a 401 error from the tomcat application. it seems, that apache fowarded the authorization request, though it shouldn't. I had to remove the "Authorization"
parameter from the request header.
To do this. I enabled mod_headers
and added RequestHeader unset "Authorization"
just before the ProxyPass directives.
So my config looks like the following now:
<VirtualHost *:80>
ProxyRequests Off
ProxyPreserveHost On
RequestHeader unset "Authorization"
<Location "/tickets/rest/">
Satisfy Any
Order allow,deny
Allow from all
</Location>
<Location />
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require user myuser
</Location>
ProxyPass /tickets http://localhost:8081/tickets
ProxyPassReverse /tickets http://localhost:8081/tickets
</VirtualHost>
EDIT:
Jira uses its own REST-API for the gadgets, so I had to define a Location-Tag for /tickets/rest
path.
- removed proxy-tag
- added Location-Tag for the jira-rest API
Got ideas to solve the problem from:
Best Answer
Try this Apache configuration: