flame
flame copied to clipboard
[Feature Request] Host Flame on a subfolder (rather than a subdomain)
I recently installed Flame and attempted to configure a subfolder reverse proxy (mydomain.com/flame) instead of a subdomain (flame.mydomain.com) using rewrites on Nginx, but didn't have any luck.
Many self-hosted applications allow a base URL setting (either within the application or as an environmental variable) to appropriately redirect paths to allow this.
Is this something that would ever be considered? If not, could someone provide a 'rewrite' rule that might accommodate this?
Below is what I'm currently using that doesn't see to be working:
location /flame/ {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
set $upstream_app flame;
set $upstream_port 5005;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
rewrite /flame/(.*) /$1 break;
}
I've also tried rewrite /flame(.*) $1 break; but had similar results.
Same, here, tried everything with NGINX and Traefik. No luck.
looking at the request made in browser the app enforce the / path so I think it need to support relative paths, don’t know exactly (I’m not a developer) but maybe removing "%PUBLIC_URL%/" from href in client/public/index.html will do the job or else the application need some kind of form to rewrite the path itself. for reference found this funcion:
function changeUrl(req, url) {
const parsedUrl = new URL(url);
req.url = url;
req.originalUrl = url;
req.path = parsedUrl.pathname;
req.search = parsedUrl.search;
req._parsedUrl = parsedUrl;
const query = {};
for(const entry of parsedUrl.searchParams) {
query[entry[0]] = entry[1];
}
req.query = query;
}
https://stackoverflow.com/questions/13446030/rewrite-url-path-using-node-js
I tried with nginx sub_filter module but i got stuck with some api requests and socket connection. Nginx send everything as 200 and when i look at the source look like working but after /flame/api/config requests which was success, validate,weather,apps or any other request doesn't even try to run. If someone else wanna try something else here is my nginx config;
location /flame/ {
proxy_pass http://127.0.0.1:5005/;
# .... other configs #
sub_filter_types text/css text/javascript text/js application/json application/javascript;
sub_filter 'href="/' 'href="/flame/';
sub_filter ',url(/' ',url(/flame/';
sub_filter 'src="/static' 'src="/flame/static';
sub_filter '"/api' '"/flame/api';
sub_filter '"/socket' '"/flame/socket';
sub_filter_once off;
}
I think adding "homepage": "./" to client/package.json should make all links in html relative.
Edit: But I don't know how to do this in react-router.
In case you wanted to do this because you have a domain from duckdns or similar domain providers, where you are already using a subdomain as domain.duckdns.org I would suggest that you use a fourth level domain like flame.domain.duckdns.org. There is a really nice article about why subfolder is a common issue.
I already have flame.domain.com and it works, but I wanted to limit / secure the site using the rules based on IP address instead of the access list., but it isn’t working for some reason.
Coming across this issue today, I am trying to make https://example.com/ lead to Flame while still serving static files like https://example.com/foo.txt. I would use a ProxyPass exclusion directive but these files change all the time. Has anyone figured this out, or has a base URL option been added?