0xJacky / nginx-ui

Yet another WebUI for Nginx
https://nginxui.com
GNU Affero General Public License v3.0
5.75k stars 410 forks source link

Cannot read properties of undefined (reading 'status') #107

Closed sochanged closed 1 year ago

sochanged commented 1 year ago

1、使用过程中遇到这样的问题: 这是在错误日志中显示出来的报错,伴随面板上体现的错误是当点击“配置管理”标签时,无法打开页面,顶部报错内容为:Cannot read properties of undefined (reading 'status') ,读取标志持续转动(请见下面截图)。

2023/04/26 16:00:03 [crit] 1524#1524: *41 mkdir() "/usr/share/nginx/html/nginx-ui/api" failed (2: No such file or directory) while reading upstream, client: xxx.yyy.zzz.aaa, server: ab.abc.com, request: "POST /nginx-ui/api/nginx_log?page=0 HTTP/2.0", upstream: "http://127.0.0.1:2053/api/nginx_log?page=0", host: "ab.abc.com", referrer: "https://ab.abc.com/nginx-ui/"
2023/04/26 16:00:09 [crit] 1524#1524: *40 mkdir() "/usr/share/nginx/html/nginx-ui/api" failed (2: No such file or directory) while reading upstream, client: xxx.yyy.zzz.aaa, server: ab.abc.com, request: "POST /nginx-ui/api/nginx_log?page=0 HTTP/2.0", upstream: "http://127.0.0.1:2053/api/nginx_log?page=0", host: "ab.abc.com", referrer: "https://ab.abc.com/nginx-ui/"
2023/04/26 16:00:09 [crit] 1524#1524: *41 mkdir() "/usr/share/nginx/html/nginx-ui/api" failed (2: No such file or directory) while reading upstream, client: xxx.yyy.zzz.aaa, server: ab.abc.com, request: "POST /nginx-ui/api/nginx/test HTTP/2.0", upstream: "http://127.0.0.1:2053/api/nginx/test", host: "ab.abc.com", referrer: "https://ab.abc.com/nginx-ui/"

我设置了将 "http://域名:端口号码/" 跳转为”http://域名/nginx-ui/“ 不知道跟这有么有关系…… 因为配置改动的地方比较多,我已经不确定是在哪一段配置之后出现的这个问题……因为我技术很菜,请谅解!

错误屏幕截图: 屏幕截图 2023-04-27 004633

系统信息:

麻烦大佬给看看可能是什么原因造成的~

2、另外有个建议,能否在偏好设置中加入“HTTP 监听端口“的设置选项(就像HTTP Challenge 监听端口那样)?

3、还有一个使用中的疑问,就是我不管怎么设置用nginx-ui代理本地服务器上本地的静态网页,都无法正常打开(另外来说,其他协议的节点又都可以正常工作),取而代之的是永远指向nginx的默认页面如下图: 屏幕截图 2023-04-27 010654 不知大佬有没有时间给科普一下在您的nginx-ui面板中在哪个模块中、怎么设置这静态页面。

0xJacky commented 1 year ago
  1. 请提供一下 nginx 配置文件
  2. 这个可能不能提供,因为如果误修改了,反向代理会出问题
  3. 麻烦提供一下配置文件
sochanged commented 1 year ago

nginx配置文件nginx.conf如下(我的静态页面实际存放位置为:“/var/www/html”):


`user root;

worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/.conf; events { worker_connections 1024; } http { types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; map $http_x_forwarded_for $clientRealIp { "" $remote_addr; ~^(?P[0-9.|:|a-f.|:|A-F.|:]+),?.$ $firstAddr; } map $http_upgrade $connection_upgrade { default upgrade; '' close; } log_format main escape=json '$clientRealIp $remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$http_host"'; access_log /var/log/nginx/access.log main; client_max_body_size 20m; server_tokens off; sendfile on; sendfile_max_chunk 512k; tcp_nopush on; tcp_nodelay on; proxy_store on; reset_timedout_connection on; send_timeout 900; charset 'UTF-8'; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; include /etc/nginx/conf.d/.conf; include /etc/nginx/sites-enabled/; upstream xray-ui { least_conn; keepalive 1000; server 127.0.0.1:8443 fail_timeout=30s max_fails=3; } server { listen 443 ssl; server_name ab.ABC.com; ssl_certificate /etc/ssl/cert/cert.crt; ssl_certificate_key /etc/ssl/cert/cert.key; ssl_session_timeout 1d; ssl_session_cache shared:MozSSL:10m; ssl_session_tickets off; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers off; location /nginx-ui/ { 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_set_header X-Forwarded-Proto $scheme; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_pass http://127.0.0.1:2053/; } location /12345/ { proxy_redirect off; 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_ssl_session_reuse off; proxy_ssl_server_name on; proxy_buffering off; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_http_version 1.1; proxy_set_header Accept-Encoding ""; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_pass http://xray-ui; proxy_set_header Connection "keep-alive"; proxy_store off; } } }`


sites-available中的default配置如下:


` map $http_upgrade $connection_upgrade { default upgrade; '' close; }

server { listen 80 default_server; listen [::]:80 default_server;

root /var/www/html;

index index.html index.htm;
server_name _;

location /.well-known/acme-challenge {
    proxy_set_header Host $host;
    proxy_set_header X-Real_IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
    proxy_pass http://127.0.0.1:9180;
}

}

server { listen 443 ssl http2; listen [::]:443 ssl http2; servername ;

index index.html index.htm;
ssl_certificate /etc/ssl/cert/cert.crt;
ssl_certificate_key /etc/ssl/cert/cert.key;
location /.well-known/acme-challenge {
    proxy_set_header Host $host;
    proxy_set_header X-Real_IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
    proxy_pass http://127.0.0.1:9180;
}
# #Vmess
location /5d51ec47-5e94-4b78-fd2a-50446548e713 {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    client_max_body_size 1000m;
    proxy_redirect off;
    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_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:2087/;
}
# #Vless
location /6d0d39b4-b3e5-466e-8ed5-696f47a5f8a6 {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    client_max_body_size 1000m;
    proxy_redirect off;
    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_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:2083/;
}
## Trojan
location /eqJWsRJCuw {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    client_max_body_size 1000m;
    proxy_redirect off;
    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_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:2096/;
}

}`


Xray配置文件“/usr/local/xray-ui/bin/config.json”如下:


` {

"log": null, "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "inboundTag": [ "api" ], "outboundTag": "api", "type": "field" }, { "type": "field", "domain": [ "www.gstatic.com" ], "outboundTag": "direct" }, { "type": "field", "domain": [ "geosite:category-ads-all", "geosite:cn", "geosite:geolocation-cn" ], "outboundTag": "blocked" }, { "type": "field", "ip": [ "geoip:cn" ], "outboundTag": "blocked" } ] }, "dns": null, "inbounds": [ { "listen": "127.0.0.1", "port": 62789, "protocol": "dokodemo-door", "settings": { "address": "127.0.0.1" }, "streamSettings": null, "tag": "api", "sniffing": null }, { "listen": null, "port": 2087, "protocol": "vmess", "settings": { "clients": [ { "id": "5d51ec47-5e94-4b78-fd2a-50446548e713", "alterId": 0 } ], "disableInsecureEncryption": false }, "streamSettings": { "network": "ws", "security": "none", "wsSettings": { "path": "/5d51ec47-5e94-4b78-fd2a-50446548e713", "headers": {} }, "sockopt": { "tcpFastOpen": false, "domainStrategy": "AsIs", "tcpcongestion": "bbr", "acceptProxyProtocol": false, "tcpKeepAliveIdle": 0, "tcpKeepAliveInterval": 0, "interface": "" } }, "tag": "inbound-2087", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] } }, { "listen": null, "port": 2083, "protocol": "vless", "settings": { "clients": [ { "id": "6d0d39b4-b3e5-466e-8ed5-696f47a5f8a6", "flow": "" } ], "decryption": "none", "fallbacks": [] }, "streamSettings": { "network": "ws", "security": "none", "wsSettings": { "path": "/6d0d39b4-b3e5-466e-8ed5-696f47a5f8a6", "headers": {} }, "sockopt": { "tcpFastOpen": false, "domainStrategy": "AsIs", "tcpcongestion": "bbr", "acceptProxyProtocol": false, "tcpKeepAliveIdle": 0, "tcpKeepAliveInterval": 0, "interface": "" } }, "tag": "inbound-2083", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] } }, { "listen": null, "port": 2096, "protocol": "trojan", "settings": { "clients": [ { "password": "eqJWsRJCuw" } ], "fallbacks": [] }, "streamSettings": { "network": "ws", "security": "none", "wsSettings": { "path": "/eqJWsRJCuw", "headers": {} }, "sockopt": { "tcpFastOpen": false, "domainStrategy": "AsIs", "tcpcongestion": "bbr", "acceptProxyProtocol": false, "tcpKeepAliveIdle": 0, "tcpKeepAliveInterval": 0, "interface": "" } }, "tag": "inbound-2096", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] } } ], "outbounds": [ { "protocol": "freedom", "settings": {} }, { "protocol": "blackhole", "settings": { "response": { "type": "http" } }, "tag": "blocked" } ], "transport": null, "policy": { "system": { "statsInboundDownlink": true, "statsInboundUplink": true }, "levels": { "0": { "handshake": 2, "connIdle": 120, "uplinkOnly": 1, "downlinkOnly": 1 } } }, "api": { "services": [ "HandlerService", "LoggerService", "StatsService" ], "tag": "api" }, "stats": {}, "reverse": null, "fakeDns": null } ` 实在是不好意思,请原谅我太菜了,这个代码框我就是弄不好……我已经非常尽力了,上面这些就是我这一个礼拜自己瞎鼓捣的结果,一个礼拜之前,我从来没用过没有UI界面的工具软件……万望海涵!给您添麻烦了!

0xJacky commented 1 year ago

配置到子目录的话可以参考这个

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name <your_server_name>;
    ssl_certificate /path/to/ssl_certificate;
    ssl_certificate_key /path/to/ssl_certificate_key;
    location /nginx-ui/ {
        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_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
        proxy_pass http://127.0.0.1:<listen_port>/;
    }
}

如果你也是这样写的,试试 reload一下 nginx。

0xJacky commented 1 year ago

创建了新站点之后要点启用才行,不然就会显示默认的页面

0xJacky commented 1 year ago

噢,你 nginx.conf 没有include sites-enabled/*.conf 所以 UI 添加的东西都没有生效

0xJacky commented 1 year ago

总的来说,你不应该把所有站点的配置文件放在 nginx.conf 中。相关配置的细节建议您先配置 Nginx UI 中的 ChatGPT Token,然后使用在线助手解答您在配置上的问题。按照我说的改完应该就可以了,这并没有涉及到 Nginx UI 设计上的问题,我就先关掉这个 issue 了。

如果后面还是无法正常使用,建议您先还原配置,然后在 nginx.conf 中 include sites-enabled/*.conf,reload nginx,之后先不使用 cf 加速,逐步调试检查问题。