Score:0

Reverse proxy serving html linked content as 404

lt flag

I've set up this reverse proxy to route a simple web page served on a port (say 61185). Instead of querying example.net:61185, i'd like to have the same behavior with example.net/listing

Here's the config:

server {
  listen 80;
  server_name example.net;
  location /listing {
    proxy_pass http://127.0.0.1:61185/;
  }
}

The html loads fine, but when fetching the css linked inside it I get a 404. I noticed the URI is http://example.net/styling.css, how can I make it so that the css is also fetched with the /listing suffix?

Lex Li avatar
vn flag
Then add another `location` section to forward `.css` requests.
Deux Sorbets avatar
lt flag
I simplified the example, isn't there a way to do that for all linked content in the page? Ideally I'd like this to be extensible to other more complex pages.
Lex Li avatar
vn flag
If you are writing the web app/page, please go to Stack Overflow and learn how to design from day 1 to work with reverse proxy. Then you don’t need too many rules.
Score:0
us flag

The issue you are experiencing is that the URLs for the linked CSS resources in the HTML page are not being rewritten to include the /listing prefix, so the browser is requesting them from the wrong location. Try this block of code:

server {
  listen 80;
  server_name example.net;
  location /listing {
    proxy_pass http://127.0.0.1:61185/listing;
    proxy_redirect /listing /;
  }
}
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.