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.

Static resources not loaded behind nginx reverse proxy

See original GitHub issue

Hi,

I have an issue which may be related to #54 or #96. When using a nginx reverse proxy (using your Docker image), static resources are not loaded, so the webpage looks like this: image

I get no error in the console, but the only request the browser does are for the main html file and favicon.ico. So I assume the issue may have to do with headers. When accessing the service directly, it works fine. I tried using Vivaldi and Firefox, and disabling my adblocker.

My nginx configuration (I tried removing the proxy_set_header lines, did not change anything):

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name download.domainname.tld;

    ssl_certificate           /etc/letsencrypt/live/default/fullchain.pem;
    ssl_certificate_key       /etc/letsencrypt/live/default/privkey.pem;

    access_log /var/log/nginx/youtubedl.access.log compression_logging;
    error_log /var/log/nginx/youtubedl.error.log;

    # This is the internal Docker DNS, cache only for 30s
    # Required to set define upstreams with variables
    # See https://sandro-keil.de/blog/let-nginx-start-if-upstream-host-is-unavailable-or-down/
    resolver 127.0.0.11 valid=30s;

    location / {
        set $upstream http://container_name:80;
        proxy_pass $upstream;
        proxy_redirect $upstream https://download.domainname.tld;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $server_name:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

And the headers: >> curl https://download.domainname.tld -I HTTP/2 200 server: nginx/1.17.8 date: Thu, 11 Jun 2020 07:53:54 GMT x-powered-by: Express access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization access-control-allow-origin: https://download.domainname.tld strict-transport-security: max-age=63072000; includeSubdomains; x-frame-options: sameorigin x-content-type-options: nosniff x-xss-protection: 1; mode=block

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vfauthcommented, Aug 29, 2020

Okay, so this issue was resolved by tweaking nginx config:

  • I added add_header Access-Control-Allow-Origin *;, which is not very good security-wise
  • I removed add_header X-Content-Type-Options nosniff; (thanks to #96)

However, these steps should not be necessary. Moreover, judging by #96, many people have that kind of issues.

Why not include a nginx server in the Docker image instead of using Node? That would probably resolve everything.

0reactions
GlassedSilvercommented, May 25, 2022

Coming just from issue #122 and hence looking at the whole web-server topic here again and seeing how it seems to help people with performance I’m curious if we could target looking into this for a 4.5 milestone, @Tzahi12345?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nginx reverse-proxy not serving static files - Stack Overflow
Setup #3 (not working!) Reverse proxy and React App with nginx. Loads index.html, but fails so load files in /static. nginx.conf (reverse-proxy)
Read more >
nginx serve static files AND reverse proxy - Server Fault
I want the browser to be in constant communication (websocket) with my backend servers as they are constantly receiving data ...
Read more >
Nginx reverse proxy is working except static files (images, etc ...
When I enter my domain and I can see IIS''s webpage but there are no static files (images, css, etc).
Read more >
Pitfalls and Common Mistakes | NGINX
Easy, right? Check if the requested URI exists and can be served by NGINX. If not, check if it is a directory that...
Read more >
How to serve static asset files with Flask and NGINX - Linode
For a web app that's using a flask reverse proxy with NGINX and gunicorn: The problem I'm having is when I try to...
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