I have an Apache 2 frontend, that serves two kinds of requests:
- Requests to the root folder (e.g. http://mysite.com/ and http://mysite.com/help) are served by the apache itself (PHP/Wordpress).
- Specific requests to the '/playapp' subfolder are forwarded to Play! via a reverse proxy via mod-proxy:
mod-proxy.conf
ProxyPass /playapp/ http://localhost:9000/
ProxyPassReverse /playapp/ http://localhost:9000/
The end result is that requests to say http://mysite.com/playapp/Controller/action
reach the Play server as http://localhost:9000/Controller/action
Now, Play! serves the page correctly, but all links, including javascript, css and links to other pages, are broken. For example, if a view uses:
#{stylesheet 'style.css' /}
Then the rendered result is
<link rel="stylesheet" type="text/css" href="/public/stylesheets/style.css" charset="utf-8" ></link>
So the end user tries to fetches http://mysite.com/public/stylesheets/style.css
, which returns a 404 because it's not actually part of the Play! app.
What's the correct way to configure Apache + Play to play along here?
The result I'm looking for is for Play! to return URLs such as this in the final rendered HTML (or perhaps for Apache to rewrite the URLs accordingly): http://mysite.com/playapp/public/stylesheets/style.css
Also, I do need some ability to link outside of the Play app. For example, I want the home route (/) to be mapped to my absolute root (http://mysite.com/
), not to Play's root.