Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Missing js and css when using a reverse Proxy in a subdirectory #30

Open
sherlockedBBC opened this issue Feb 9, 2021 · 3 comments
Open
Assignees
Labels

Comments

@sherlockedBBC
Copy link

Version: 0.5.3

I am using traefik as a reverse proxy in front of speedtest. traefik is configured to forward requests to example.com/speedtest/ to speedtest and strip the /speedtest/ prefix. To speedtest, it looks like it is simply hosted in a root directory.

When accessing the site the HTML is loaded but the icon, js, and CSS files are not loaded because the path is example.com/app.js and not example.com/speedtest/app.js. If I change the path manually in my browser I get a 200 response.

Github Issue

@e7d e7d added the bug label Feb 19, 2021
@e7d
Copy link
Owner

e7d commented Feb 19, 2021

Hi @sherlockedBBC,

Yeah you're right. That is a genuine, that should be relatively simple to fix.
I'll give it a look some time and produce a fix.

Regards.

@e7d e7d self-assigned this Feb 19, 2021
@aniqueta
Copy link

Thanks @e7d.

In the meantime, is there a workaround? Trying the following in nginx, which normally works for sub-directories, didn't do the trick for me:

        location /speedtest {
                return 301 $scheme://$host/speedtest/;
        }

        location ^~ /speedtest/ {
                rewrite /speedtest(.*) $1 break;
                proxy_pass http://127.0.0.1:5080;
                client_max_body_size 256M;
        }

        if ($http_referer ~* /speedtest) {
                rewrite ^/(.*) /speedtest/$1? redirect;
        }

@JoshMcCullough
Copy link

Also need this. I was able to hack my way around it by doing this in NGINX but it ain't pretty and ain't what we want to do (YMMV):

location ~ "^/(ip|ping|run|config.json|(app|icons|worker)\..{8}\.(css|js|woff|woff2|ttf))$" {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    auth_jwt_enabled off;
    gzip off;
    proxy_pass http://localhost:5080;
}

location /speed-test {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    auth_jwt_enabled off;
    gzip off;
    proxy_pass http://localhost:5080/;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants