Gozargah / Marzban

Unified GUI Censorship Resistant Solution Powered by Xray
https://t.me/gozargah_marzban
GNU Affero General Public License v3.0
3.35k stars 465 forks source link

Hosting on specific location with NGINX #1085

Open datew0 opened 3 months ago

datew0 commented 3 months ago

Describe the bug I am using NGINX as reverse proxy to host Marzban on https://example.com/mb/ and accessing Dashboard on https://example.com/mb/dashboard respectively. I can successfully get HTML page of Dashboard using following location in nginx.conf (works well with AdGuard Home):

location /mb/ {
    proxy_cookie_path / /mb/;
    proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_redirect ~^/(.*) $scheme://$http_host/mb/$1;
        proxy_pass http://127.0.0.1:8000/;
}

‼️ But the problem is that paths of resources in received HTML page are hardcoded to /dashboard instead of /mb/dashboard (see attached screenshot)

❓ Is there a way to tell Marzban that it is placed behind reverse proxy on specific location OR migrate to relative paths for resources?

To Reproduce Steps to reproduce the behavior:

  1. Run NGINX with provided configuration and Marzban
  2. Open https://example.com/mb/dashboard/ in browser
  3. See returned HTML and empty page

Expected behavior Login page of Dashboard should successfully catch all needed resources and open with provided NGINX configuration.

Screenshots

Снимок экрана 2024-07-04 в 19 55 44
SaintShit commented 3 months ago

Hi currently, you could handle /dashboard in your nginx config and replace it with your desired path. of course this isn't the best way to do that. Dynamic dashboard path is implemented on next branch and gonna release with next major update.

datew0 commented 3 months ago

Thank You for quick reply! I tried docker.io/gozargah/marzban:next image — not working. It’s strange that next branch hasn’t recieve updates for 2 months. Maybe, there is fresh version of next branch?

mmsh1370 commented 1 week ago

Hi currently, you could handle /dashboard in your nginx config and replace it with your desired path. of course this isn't the best way to do that. Dynamic dashboard path is implemented on next branch and gonna release with next major update.

hello Is it possible to explain how to do this? I am not familiar with ngnix and this issue took me a long time and I could not find the solution Of course, I wanted to be able to connect to a dashboard and Submarzban with several different domains, and so far I have found the solution. But I did not find the solution to be able to replace a path with ngnix so that the dashboard opens with a non-default path or the sub links open with a non-default path.

سلام امکانش هست توضیح بدین چطور باید این کار رو انجام داد من به ngnix مسلط نیستم و این موضوع خیلی وقت از من گرفت و راه حلش رو نتونستم پیدا کنم البته من میخواستم با چندین دامنه ی مختلف بتونم به یک داشبورد و ساب مرزبان متصل بشم و تا اینجا راه حلش رو پیدا کردم ولی راه حل اینکه بتونم یک مسیر رو جایگزین کنم با ngnix که داشبورد با مسیر غیر پیشفرض باز بشه و یا لینک های ساب با مسیر غیر پیشفرض باز بشن پیدا نکردم