power_528 2021-09-23 13:56
浏览 151
已结题

Nginx跨域问题和登录后访问退回到登录界面

测试环境:
建立了一个Centos虚拟机:
(1)虚拟机IP:192.168.31.13/24
(2)本机IP: 192.168.31.190/24
在其上安装了mysql、redis、netcore3.1和nginx四个服务,并把netcore3.1的发布包部署到了nginx服务中相应目录中,即在/usr/local/nginx/html目录下,同时把四个服务都能正常启动。

Nginx.conf配置文件内容:

worker_processes  1;
events {
            worker_connections  1024;
}
http {
       include  mime.types;
       default_type  application/octet-stream;
       sendfile  on;
       keepalive_timeout  65;
       server {
                   listen 8080; 
                  server_name 192.168.31.13;
                  root html;
                  index index.html index.htm;
                  proxy_pass http://localhost:5000;
                  }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

appsettings.json文件内容:(/usr/local/nginx/html/wwwroot)

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "JwtSettings": {
    "Issuer": "https://www.xyz.cn",
    "Audience": "https://www.xyz.cn",
    "SecretKey": "www.xyz.cn/app" 
  },
  "Snowflake": {
    "DataCenterId": "1",
    "MachineId": "1"
  }, 
  "PublicConnectionStrings": {
    "MySql": "Data Source=192.168.31.13;Database=steel_public;User ID=root;Password=root;allowPublicKeyRetrieval=true;pooling=true;CharSet=utf8;port=3306;sslmode=none;",
  },
  "ConnectionStrings": {
    "MySql": "Data Source=192.168.31.13;Database={0};User ID=root;Password=root;allowPublicKeyRetrieval=true;pooling=true;CharSet=utf8;port=3306;sslmode=none;",
    "Redis": "192.168.31.13:6379,password=123456"  
},
  "DbType": "MySql",
  "AllowedHosts": "*;http://192.168.31.13:5000;http://192.168.31.13:8080;http://192.168.31.13:5001;http://192.168.31.13:80;http://localhost:5000;http://localhost:80;http://localhost:8080;",
  "RedisConnection": "192.168.31.13:6379,password=123456"
}

config.js文件内容:

/usr/local/nginx/html/wwwroot/static/js/config.js:
window.g = {
    baseUrl: 'http://192.168.31.13:8080/',
    debug: false,
    lodop_preview: false
}

目前测试结果和存在问题:
(1)在宿主机上,使用firefox通过http://localhost:5000或http://127.0.0.1:5000能够登录,且能访问项目中所有模块的数据;
(2)在宿主机上,使用firefox通过http://192.168.31.13:8080能够登录,但访问项目每个模块中最后一级模块时会退回到登录界面的数据;
(3)在外网主机上,使用firefox通过http://192.168.31.13:8080访问时,能够显示出登录界面,但不能登录出现CORS跨域问题。

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 10月1日
    • 创建了问题 9月23日

    悬赏问题

    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3