alireza0 / x-ui

xray panel supporting multi-protocol multi-user expire day & traffic (Vmess & Vless & Trojan & Shadowsocks)

Home Page:https://t.me/XrayUI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

1.8.4 Can't access panel if setupped Listen URL parametr

UdoChudo opened this issue · comments

commented

Describe the bug
After upgrading x-ui image from 1.8.3 to 1.8.4 i can't access to my panel

My setup:
INTERNET -> NGINX with https://example.com/x-ui/ > http://ip:port/x-ui/

To Reproduce
Steps to reproduce the behavior:

  1. Setup x-ui to listen Domain (example.com)
    image

  2. Setup x-ui URI path
    image

  3. Setup nginx with example.com/x-ui/ location
    Nginx Config

location /x-ui/ {
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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_read_timeout 52w;
        proxy_pass http://ip:port/x-ui/;
        }
  1. Get access error
    image

I have a similar problem on v1.8.4. When Listen Domain is set, access to the panel is not possible.
Downgrading to v1.8.3 resolved the issue.

I don't know if this information is helpful:
I'm not using Nginx reverse proxy.
I'm using cloudflare CDN proxy to access the panel (on a non-standard port, utilizing cloudflare's origin rules to rewrite destination port number)

Using Listen Domian is to limit access to the panel only by this domain.

If you have problem, you should debug the proxy and receved requests.
You can test it simply by a curl command:

curl -H "Host: example.com" http://ip:port/x-ui

x-ui installed on a test VM, no tls,
webDomain example.com
webBasePath /path/

Version 1.8.3

root@debian:~# curl http://127.0.0.1:54321/path/ -i
HTTP/1.1 403 Forbidden
Date: Sat, 29 Jun 2024 14:58:33 GMT
Content-Length: 0

root@debian:~# curl -H "Host: example.com" http://127.0.0.1:54321/path/ -i
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Sat, 29 Jun 2024 14:58:54 GMT
Transfer-Encoding: chunked

<!DOCTYPE html>
<html lang="en">
...

Upgraded to version 1.8.4

root@debian:~# curl http://127.0.0.1:54321/path/ -i
HTTP/1.1 403 Forbidden
Date: Sat, 29 Jun 2024 15:01:54 GMT
Content-Length: 0

root@debian:~# curl -H "Host: example.com" http://127.0.0.1:54321/path/ -i
HTTP/1.1 403 Forbidden
Date: Sat, 29 Jun 2024 15:09:25 GMT
Content-Length: 0

I tested something else, If I include port number in Host header, the request succeeds:

version 1.8.4

root@debian:~# curl -H "Host: example.com" http://127.0.0.1:54321/path/ -i
HTTP/1.1 403 Forbidden
Date: Sat, 29 Jun 2024 15:49:13 GMT
Content-Length: 0

root@debian:~# curl -H "Host: example.com:54321" http://127.0.0.1:54321/path/ -i
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Sat, 29 Jun 2024 15:49:27 GMT
Transfer-Encoding: chunked

<!DOCTYPE html>
<html lang="en">
...

OK! I have found it.
It happened after this change: 6c36c19

It seems gin package has an issue with this from long time ago.
I will role it back.

This problem is now solved and will be available in next release