Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard page cannot load static files #1377

Open
KurimuzonAkuma opened this issue Oct 17, 2024 · 31 comments
Open

Dashboard page cannot load static files #1377

KurimuzonAkuma opened this issue Oct 17, 2024 · 31 comments

Comments

@KurimuzonAkuma
Copy link

KurimuzonAkuma commented Oct 17, 2024

Describe the bug
When opening the dashboard it opens just a white page with no css styles or js scripts.

To Reproduce
Steps to reproduce the behavior:

  1. Just install the 0.7.0 version of marzban, set proxy_pass in nginx and open the page.

Expected behavior
The page loads and displays the dashboard.

Screenshots
image

Machine details (please complete the following information):

  • OS: Debian 12
  • Python version: From the docker
  • Nodejs version: From the docker
  • Browser: Tested on chrome, ms edge and arc

Additional context
Marzban installed via sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install.

My nginx config:
image

@M03ED
Copy link
Collaborator

M03ED commented Oct 17, 2024

did you try reinstalling marzban ?

@KurimuzonAkuma
Copy link
Author

did you try reinstalling marzban ?

Yes, but doesnt help :(

@ImMohammad20000
Copy link
Collaborator

ImMohammad20000 commented Oct 17, 2024

did you change dashboard path ?

@KurimuzonAkuma
Copy link
Author

did you change dashboard path ?

Same with default and custom path

@M03ED
Copy link
Collaborator

M03ED commented Oct 17, 2024

try to set ssl and access directly to dashboard, see what happen

@KurimuzonAkuma
Copy link
Author

KurimuzonAkuma commented Oct 17, 2024

try to set ssl and access directly to dashboard, see what happen

I dont have certs so i connect via ssh -L 1234:localhost:1234 user@ip and it works fine. I have problem only with nginx :(

Everything worked fine on version 0.6.0...

@M03ED
Copy link
Collaborator

M03ED commented Oct 17, 2024

so the problem is your nginx configuration...

@KurimuzonAkuma
Copy link
Author

so the problem is your nginx configuration...

The configuration is shown in the screenshot above and was taken from the README. What could be wrong there? 🤔

@M03ED
Copy link
Collaborator

M03ED commented Oct 17, 2024

The configuration is shown in the screenshot above and was taken from the README. What could be wrong there? 🤔

im not familiar with nginx but if you jujst use nginx to set ssl, i suggest try haproxy
that may solve your problem ( im currently using haproxy )

@arsamme
Copy link

arsamme commented Oct 17, 2024

Add statics to your nginx location regex

@KurimuzonAkuma
Copy link
Author

Add statics to your nginx location regex

Same 😢

@arsamme
Copy link

arsamme commented Oct 17, 2024

Adding statics to nginx location regex and restarting nginx using this command should work:
systemctl restart nginx

Another solution is to forward any request of a domain/sub-domain to Marzban without using location regex, Like me:
image

@M03ED
Copy link
Collaborator

M03ED commented Oct 18, 2024

Fixed ?

@KurimuzonAkuma
Copy link
Author

Fixed ?

No :(

@fodhelper
Copy link
Contributor

damn, this happened to me too, after updating to the latest dev, that damn Dashboard path change PR

instead of https://***.com/dashboard/statics/index.aea8a8e4.js browser looks for https://***.com/statics/index.aea8a8e4.js

@fodhelper
Copy link
Contributor

If your dashboard domain is behind Cloudflare, you need to disable it's cache by enabling Development Mode
And redirect /statics to /dashboard/statics until someone fix the dashboard
you can redirect using Cloudflare 'Redirect Rules' page or your reverse proxy software

@M03ED
Copy link
Collaborator

M03ED commented Oct 21, 2024

@iambabyninja

@GawrAme
Copy link

GawrAme commented Oct 22, 2024

i got this error too, revert back to 0.6.0 until someone provide fixing :(
do not recommend me another app like haproxy or caddy, im not familiar with those app xD

@GawrAme
Copy link

GawrAme commented Oct 22, 2024

Adding statics to nginx location regex and restarting nginx using this command should work: systemctl restart nginx

Another solution is to forward any request of a domain/sub-domain to Marzban without using location regex, Like me: image

ohh, fix with adding statics to regex.
Thank you sir

@iambabyninja
Copy link
Contributor

iambabyninja commented Oct 22, 2024

  1. Update marzban
  2. Clear browser(site) cache
  3. If you use nginx, add /statics/
location ~* /(sub|dashboard|statics|api|docs|redoc|openapi.json) {
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

In the new version of the dashboard, there are no routes for /dashboard/statics in the code. Therefore, if you see requests to these addresses, it means you are using a cached version.
If the /statics/ folder is not accessible, you need to update your nginx configuration as shown in the example above.

@KurimuzonAkuma
Copy link
Author

  1. Update marzban
  2. Clear browser(site) cache
  3. If you use nginx, add /statics/
location ~* /(sub|dashboard|statics|api|docs|redoc|openapi.json) {
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

In the new version of the dashboard, there are no routes for /dashboard/statics in the code. Therefore, if you see requests to these addresses, it means you are using a cached version. If the /statics/ folder is not accessible, you need to update your nginx configuration as shown in the example above.

It's not working for me for some reason. Tried even redirecting /statics to /dashboard/statics via nginx/Redirect Rules in Cloudflare, but I still get a 404 error for js and css files.

@iambabyninja
Copy link
Contributor

  1. Update marzban
  1. Clear browser(site) cache
  1. If you use nginx, add /statics/

location ~* /(sub|dashboard|statics|api|docs|redoc|openapi.json) {

    proxy_redirect off;

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection "upgrade";

    proxy_pass http://127.0.0.1:8000;

    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

In the new version of the dashboard, there are no routes for /dashboard/statics in the code. Therefore, if you see requests to these addresses, it means you are using a cached version. If the /statics/ folder is not accessible, you need to update your nginx configuration as shown in the example above.

It's not working for me for some reason. Tried even redirecting /statics to /dashboard/statics via nginx/Redirect Rules in Cloudflare, but I still get a 404 error for js and css files.

"Why? There are no paths like /dashboard/statics in the frontend.

I tested this PR in all possible conditions and scenarios, and it worked perfectly.
That means you are configuring something incorrectly."

@KurimuzonAkuma
Copy link
Author

"Why? There are no paths like /dashboard/statics in the frontend.

Just testing the advice from a comment #1377 (comment)

I tested this PR in all possible conditions and scenarios, and it worked perfectly. That means you are configuring something incorrectly."

But what could possibly be wrong?
Marzban is installed in docker. The domain is connected via cloudflare ns. The panel is successfully opened only if you forward the port via ssh. It was fine on the 0.6.0 version, but I don't really want to roll back.

My current nginx config:

location ~* /(sub|dashboard|statics|api|docs|redoc|openapi.json) {
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass http://localhost:5001;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

@fodhelper
Copy link
Contributor

Why? There are no paths like /dashboard/statics in the frontend.

There is, and the things i said worked for me.
image

And it's NOT browser cache
But i guess it's something about Docker, it may cached Dockerfile steps

@fodhelper
Copy link
Contributor

stopped all containers, wiped all images and containers, recreated Marzban-dev and still all static files are at '/dashboard/statics/'
There is no CDN cache, there is no browser cache, static files are literally stored at '/dashboard/statics/', there is no '/statics'

@iambabyninja
Copy link
Contributor

iambabyninja commented Oct 22, 2024

stopped all containers, wiped all images and containers, recreated Marzban-dev and still all static files are at '/dashboard/statics/'

There is no CDN cache, there is no browser cache, static files are literally stored at '/dashboard/statics/', there is no '/statics'

Test Access the container directly, for example:

curl -I -k http://127.0.0.1:8000/statics/index.9b97897c.css

Where 8000 is the port on which Uvicorn is running.

If you receive a 200 response, it means the container is serving all the necessary static files;
the issue lies in the configuration of CF, Nginx, Caddy, etc.

@fodhelper
Copy link
Contributor

Test Access the container directly

both /statics/index.9b97897c.css and /dashboard/statics/index.9b97897c.css shows error 200

I changed my reverse proxy software config to include /statics
then cleared Cloudflare Cache from 'Caching > Configuration > Purge Cache` > "Purge Everything"
And created cache rule to disable caching dashboard statics to prevent future problems
Finally problem solved, Thank you.

@janahnovin
Copy link

I have the same problem after updating to version 7, the dashboard screen is white (I'm using ngnix), has anyone been able to solve it?

@janahnovin
Copy link

My ngnix settings
server {
listen unix:/run/nginx-h1.socket proxy_protocol;

location ~* ^\/(dashboard|api|sub|docs|openapi.json).* {
    proxy_pass http://unix:/run/marzban.socket;
    set_real_ip_from unix:;
    real_ip_header proxy_protocol;
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
}

}

@iambabyninja
Copy link
Contributor

iambabyninja commented Oct 22, 2024

My ngnix settings

server {

listen unix:/run/nginx-h1.socket proxy_protocol;



location ~* ^\/(dashboard|api|sub|docs|openapi.json).* {

    proxy_pass http://unix:/run/marzban.socket;

    set_real_ip_from unix:;

    real_ip_header proxy_protocol;

    proxy_http_version 1.1;

    proxy_set_header Host $http_host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-Host $host;

    proxy_set_header X-Forwarded-Port $server_port;

}

}

add /statics/

#1377 (comment)

like

location ~* /(sub|dashboard|statics|api|docs|redoc|openapi.json) {

@janahnovin
Copy link

My ngnix settings
server {

listen unix:/run/nginx-h1.socket proxy_protocol;



location ~* ^\/(dashboard|api|sub|docs|openapi.json).* {

    proxy_pass http://unix:/run/marzban.socket;

    set_real_ip_from unix:;

    real_ip_header proxy_protocol;

    proxy_http_version 1.1;

    proxy_set_header Host $http_host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-Host $host;

    proxy_set_header X-Forwarded-Port $server_port;

}

}

add /statics/

#1377 (comment)

like

location ~* /(sub|dashboard|statics|api|docs|redoc|openapi.json) {

I installed border guard using docker and it works as single port on 443, but adding location ~* /(sub|dashboard|statics|api|docs|redoc|openapi.json) { didn't solve my problem and Dashboard page. It's still white and I had to roll back, is there a way?

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

No branches or pull requests

8 participants