admin管理员组文章数量:1405611
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>
本文标签: apacheTrick Apache2 to load assets from a sub dir when they exist in rootStack Overflow
版权声明:本文标题:apache - Trick Apache2 to load assets from a sub dir when they exist in root - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744263090a2597813.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论