Proxy keeping /url


(Vaidehi Patel) #1

Im trying to change URL of my existing app which is
abc.com {
proxy / IP:5000 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {remote}
header_upstream X-Forwarded-Proto {scheme}
}
}
TO

abc.com/consumer {
proxy / IP:5000 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {remote}
header_upstream X-Forwarded-Proto {scheme}
}
}

But this thing is not working, my Javascript files are not loading,

Anyone knows how to solve this ?


(Matthew Fay) #2

It’s a complicated problem with complicated solutions.

The upstream server acts as though it should have the web root. You browse to example.com/consumer, it tells you to load example.com/js/javascript.js (or equivalent), Caddy now doesn’t know that it has to send this upstream because it doesn’t start with /consumer.

By far the simplest solution is for the upstream server to have an option to configure a base URL - essentially telling it that it’s in a subfolder, so it can fix its own links.

If that’s off the table, you’ll need to turn to HTML filtering to fix the links on the fly.

Alternately you can configure additional proxies for the subfolders containing page assets, if those are known.


P.S. Unless you own abc.com, it’s considered bad manners to link their website in a technical context to mask your own site.