question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

assets not loading over reverse proxy (nginx)

See original GitHub issue

First of all great work on this project. You are truly thought leaders.

I am trying to serve a single instance react-starter-kit app over a nginx reverse proxy on the path name /stories - fe. the url would be http://localhost/stories.

The app itself loads fine, but the assets via webpack do not load at http://localhost/stories/assets. - where I need them to load.

Here is my nginx.conf:

worker_processes 4;

events { worker_connections 1024; }

http {

  upstream home {
    least_conn;
    server home:3001 weight=10 max_fails=3 fail_timeout=30s;
  }

  upstream stories {
    least_conn;
    server stories:3001 weight=10 max_fails=3 fail_timeout=30s;
  }

  server {
    listen 80;

    location / {
      proxy_pass http://home;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }

    location /stories {
      rewrite ^/stories(.*) /$1 break;
      proxy_pass http://stories;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
langpavelcommented, Feb 24, 2017

I think problem here is with / prefixing resources path. You must tweak public path in webpack

1reaction
tk1cnttcommented, Feb 21, 2017

I have the same issue

Access via nodejs

curl -I http://localhost:6000/assets/f66931e8.svg
HTTP/1.1 200 OK
X-Powered-By: Express
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Wed, 08 Feb 2017 14:56:10 GMT
ETag: W/"30aa-15a1e398686"
Content-Type: image/svg+xml
Content-Length: 12458
Date: Tue, 21 Feb 2017 03:28:20 GMT
Connection: keep-alive

Access via nginx

curl -I http://localhost:8001/assets/f66931e8.svg
HTTP/1.1 404 Not Found
Server: nginx/1.10.2
Date: Tue, 21 Feb 2017 03:28:33 GMT
Content-Type: text/html
Content-Length: 169
Read more comments on GitHub >

github_iconTop Results From Across the Web

NGINX Reverse proxy not loading resources
If I understand your problem correctly it sounds like the problem is your application thinks it's hosted at the root uri ...
Read more >
Can't get nginx reverse proxy to load css/images of web ...
Your website's HTML is trying to access a url that is not /test/** but /platform/images/leaves.png this means that NGINX won't try to use ......
Read more >
NGINX Reverse Proxy not loading some elements
I have set up an NGINX Reverse Proxy which is working fine and dandy for plex, my irrigation system, etc etc. It is...
Read more >
Using nginx as reverse proxy and 404 assets problems
I'm using Nginx as reverse proxy but I have a problem with it. It's not serving any asset (JS, CSS, image, etc). When...
Read more >
Nginx reverse proxy is working except static files (images ...
please check if www-data has the privileges to access your static assets.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found