[elunez/eladmin]求助:验证码无法正常生成

2024-01-29 307 views
6

请问下,我在服务端无法生成验证码

image

但在本地可以

image

不知道是什么原因呢?服务端的nginx配置,不知是否正确?proxy打头的那些配置,如果打开,会出现white page问题


    server
    {
        listen 80;
        server_name 139.x.x.x.  # 我的服务器外网IP
        index index.html;
        root  /data/chenhaolang/tools/app_test/eladmin/frontend/dist;  #dist上传的路径
        # 避免访问出现 404 错误
        location / {

          try_files $uri $uri/ @router;
          index  index.html;

        #proxy_pass http://127.0.0.1:8000; #这里的端口记得改成项目对应的哦
        #proxy_set_header X-Forwarded-Proto $scheme;
        #proxy_set_header X-Forwarded-Port $server_port;
        #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #proxy_set_header Upgrade $http_upgrade;
        #proxy_set_header Connection "upgrade";          

          #try_files $uri $uri/ @router;
          #index  index.html;
        }
        location @router {
          rewrite ^.*$ /index.html last;
        }  
    } 

}

另外,如果我想去掉验证码直接用用户名密码登录,请问应该怎么做呢?

回答

1

补充: 1、服务端的code接口

image

然后我随便填一个验证码,就会报错,无法登陆

image image

2、正常的本地、和demo网站的接口

image image
9

已解决,常规部署的nginx说的不是很清楚,后面我按照容器的方式改了一下

   server
    {
        listen 80;

        server_name 139.x.x.x

        index index.html;

        root  /data/chenhaolang/tools/app_test/eladmin/frontend/dist;  #dist上传的路径

        # 避免访问出现 404 错误
        location / {
          try_files $uri $uri/ @router;
          index  index.html;
        }

        location @router {
          rewrite ^.*$ /index.html last;
        }

        # 接口
        location /api {
          proxy_pass http://127.0.0.1:8000;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-Port $server_port;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }

        # 授权接口
        location /auth {
          proxy_pass http://127.0.0.1:8000;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-Port $server_port;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }

        # WebSocket 服务
        location /webSocket {
          proxy_redirect off;
          proxy_pass http://127.0.0.1:8000/webSocket;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_connect_timeout 60s;
          proxy_read_timeout 86400s;
          proxy_send_timeout 60s;
        }

        # 头像
        location /avatar {
          proxy_pass http://127.0.0.1:8000;
        }

        # 文件
        location /file {
          proxy_pass http://127.0.0.1:8000;
        }

    }

另外可以尝试将这段代码注释掉来跳过验证码

image