I have spent a few days researching and trying various combinations to no effect.
What I have is a web application running in a docker container on a home server on port 3000. Accessible via server.local:3000.
The app works as intended however I'd like to proxy it in a sub directory so that it is easier to remember and to add other apps accessible by their name. Eg. server.local/app.
I don't believe it is possible to configure the app to load from /app as the app nor docker contains any variables to set as a base path. So I'm looking to Apache to rewrite the resources and leave the app intact for upgradability.
I can get the app to load via a proxy
ProxyPass /app http://localhost:3000/
ProxyPassReverse /app http://localhost:3000/
However all resources the app uses (css, images, fonts) fail to load as they are coded in the HTML to look for the resource in the root dir. Eg /css/style.css /images/image.jpg instead of /myapp/css/style.css or /myapp/images/image.jpg.
Firstly, is it possible to do what I'm attempting to do? With no option in the app, can I 'trick' the app into loading the resources from another location?
Secondly, here is what I have so far for the Apache config but it still is failing to load resources with a 404 for each resource.
Any help would be much appreciated.
<Location /myapp/>
ProxyPreserveHost On
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.*\.(css|js|png|jpg|jpeg|gif|woff|woff2|ttf|svg|ico|map))$ [NC]
RewriteRule ^/dinners/_next/static/(.*)$ http://localhost:3000/$1 [P,L]
Header always set X-Frame-Options SAMEORIGIN
Header always set X-Content-Type-Options nosniff
</Location>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744263090a4565731.html
评论列表(0条)