环境搭建:
我建立了一个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文件内容:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name 192.168.31.13;
location / {
root html/wwwroot;
proxy_pass http://localhost:5000/;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
现在测试结果和遇到的问题:
(1)在宿主机上通过B/S访问:http://localhost:5000或http://127.0.0.1:5000可正常登录,并访问所有服务模块;
(2)在宿主机上通过B/S访问:http://.168.31.13:8080可正常登录,但访问每个服务模块中最后一级子模块时,会退回到登录主页;
(3)在外网通过B/S访问:http://.168.31.13:8080可正常打开登录页面,但不能登录,显示CORS跨域问题。
你需要把你的整体配置发出来,这样的话,大家才能了解情况,
目前,你只是发了简单的nginx配置,怕是很难知道,你的问题出现在什么地方。
appsettings.json文件内容:(/usr/local/nginx/html/wwwroot)
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"JwtSettings": {
"Issuer": "https://www.ezhizao.cn",
"Audience": "https://www.ezhizao.cn",
"SecretKey": "
"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;",
"MsSql": ""
},
"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
}
Thanks kk1924.