I have an app with LAN ip and Nginx server accessible at example.com/. I have proxied the server like this:

location /app/ {
    proxy_redirect http://example.com/app/;

    proxy_set_header Host $host;
    proxy_set_header Referer $http_referer;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade; # allow websockets
    proxy_set_header Connection $connection_upgrade;

The html code of this app has a tag with the src attribute set like this:

<script type="text/script" src="/foo.js">

When loading the page, the GET request for foo.js will fail because it will try to download it from example.com/foo.js and not example.com/app/foo.js.

How can I solve this?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.