Score:1

NGINX proxy_pass with html hard links

ve flag

I'm trying to run a web app listening on a different port of the same server. I'm using NGINX in order to proxy requests. I will show you an example to clarify.

server {
  listen 80;
  server_name example.org;
...
  location /app {
    proxy_pass http://localhost:8080/public/foo;
  }
...
}
...
server {
  server_name sub.example.org;
...
  location / {
    proxy_pass http://localhost:8080;
  }
...
}

When I go to http://example.org/app I can see the redirect is correct because I see the same html I can found at http://sub.example.org/public/foo, but the app at http://sub.example.org/public/foo/index.html includes some hard linked scripts.

<script type="text/javascript" src="/static/library.js"></script>

The console logs says that http://example.org/static/library.js can't be found, but this is obvious!

How can I modify the configuration in order to have index.html searching for http://sub.example.org/static/library.js?

Score:0
us flag

You need to configure your upstream application's root URL to sub.example.org. Then the application generates correct URLs to resources it loads.

I. Iudice avatar
ve flag
Can you provide an example?
us flag
You need to look at your application's documentation. You have given no information about your application, so I cannot help.
I. Iudice avatar
ve flag
Except the folder `/public/foo`, the application only uses the folder `/static` and its subfolders.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.