Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74020

Preserve base URL when loading assets on proxied web page

$
0
0

I'm trying to host a site (called site1) nested within an existing domain (www.gateway.com).

e.g. Instead of www.site1.com/profile, it would be www.gateway.com/site1/profile.

I have an NGINX reverse proxy that detects the /site1/ path and proxies it to some upstream machines:

location ~/site1/(.*)$ {
  proxy_pass http://upstreams/$1$is_args$args;

  proxy_set_header Host $host;
}

The proxy itself is working fine - it redirects all the paths correctly. However, the site's assets (e.g. JS, CSS, etc.) do not preserve the base path (www.gateway.com/site1).

e.g. It is trying to load www.gateway.com/normalize.css, when the actual asset lives at www.gateway.com/site1/normalize.css.

For reference, the HTML for site1 is sourcing assets like so:

<link href="/normalize.css" rel="stylesheet" />

I've also tried removing the leading / in the href, but this results in the asset's path including the full route (less the last fragment) - also not what is desired.

Note that site1 works fine when hosted at the root of a domain (e.g. www.gateway.com/profile).

Any insights would be helpful. Thanks!


Viewing all articles
Browse latest Browse all 74020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>