测试环境:
建立了一个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跨域问题。