proxy_pass isnt loading required resources

Maxim Dounin mdounin at mdounin.ru
Sun Feb 12 14:44:43 UTC 2017


Hello!

On Sat, Feb 11, 2017 at 09:15:51PM +0200, Georgi Minkov wrote:

> Hello :) I`m having difficulties with configuring nginx to serve 
> different applications based on the location in header.  I`m 
> successfully hit the index page but the additional resources are 
> not returned (404). Checked the url in browser console and the 
> request url is not modified with the location.  Lets say the 
> address is example.com/test .... but the next request for each 
> resource is not automatically adding the location, so remain:  
> example.com/bootstrap/3.3.7/css/bootstrap-theme.min.css
>   instead of
>   example.com/bootstrap/ test /3.3.7/css/bootstrap-theme.min.css 
>   .  If the location is added to the URL is all fine.  Kindly 
>   ask if someone can help me or give me a tip (not that i havent 
>   tried almost anything on the net), i suggest someone of you 
>   will know that or at least will tell me that is not supported.  

This is not something proxy_pass is expected to do for you 
automatically.  It only proxies the resource requested, and 
doesn't try to modify any links to other resources in the resource 
itself.  Moreover, in many cases it is not at all possible, as the 
format of the resource can be proprietary.

The best solution is to teach your backend to use either relative 
links to additional resources, or to use proper external root URL 
for resources (usually there is an configuration option for this).

You may also try to change links on the fly using the sub_filter 
directive, see http://nginx.org/r/sub_filter.  This is relatively 
costly and not going to work in all cases, but may help to 
mitigate problems till there is a possibility to fix the backend.

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx mailing list