首页 > 解决方案 > 无法使用 nginx 为 linux 服务器打开 hygieia UI

问题描述

我正在尝试在 linux 服务器上安装和运行 hygieia https://github.com/hygieia/hygieia,但是它不起作用。我在端口 3000 中启动 UI,在端口 4000 中启动 api,并使用下面的 nginx.conf 文件在 nginx 中配置它们:

events {
         worker_connections  1024;
   }
http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        server {
                   listen       3000;
                   server_name  localhost;
       location / {
                  root   html/hygieia-ui;
                  index  index.html index.htm;
     }
      error_page   500 502 503 504  /50x.html;
     location = /50x.html {
        root   html;
    }
    location ^~/api/{
        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_pass http://localhost:4000;
    } 

当我尝试使用浏览器通过 3000 端口访问 UI 时,在旋转页面之后,它会在“验证身份”页面和主 UI 页面上闪烁,然后最终停留在 http://serverip:3000/authcode 并出现错误,它无论是否启动 api,行为都相同:

1.浏览器报错:http://serverip:3000/authcode 404 Not Found

2. nginx 中的错误:[error] 4711#0: *12 open() "/usr/local/nginx/html/hygieia-ui/authcode" failed (2: No such file or directory), client:mypcip, server :本地主机,请求:“GET /authcode HTTP/1.1”,主机:“serverip:3000”,引用者:“http://serverip:3000/user/sso”

我所知道并尝试过的:

1.Same configuration works fine for my PC of Windows 10 system(including port , nginx configuration etc);
2.Mongo db has been started and curl localhost:4000/api/ping returns true ;    
3.Visiting access of port 3000 and 4000 from my PC to the linux server has been granted , and visiting serverip:4000/api/ping
with my browser returns true as well;   
4.curl localhost:3000 on linux server returns the content of index.html;

而且我注意到我的PC的nginx访问日志中没有任何关于authcode的http请求日志,但是它出现在linux服务器的日志中,如下所示:

mypcip - - [21/Jun/2021:02:39:57 -0400] "GET /authcode HTTP/1.1" 404 555 "http://serverip:3000/user/sso" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36 Edg/91.0.864.48"

我正在使用的应用程序版本:

Nodejs:v14.17.0 Npm:v6.14.13
Angular:v8.0.3
Nginx:v1.20.1
Java:openjdk v1.8.0_292 Maven:v3.6.3

任何帮助都感激不尽 !非常感谢 !

标签: node.jsangularnginxhygieia

解决方案


推荐阅读