【发布时间】:2020-01-25 11:21:24
【问题描述】:
我在 /etc/nginx/sites-available 文件夹的默认配置文件中有以下内容
server {
listen 80;
location / {
proxy_pass http://10.XX.XX.XX:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 81;
location / {
proxy_pass http://10.XX.XX.XX:5050;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
这适用于http://10.XX.XX.XX/,并显示了.net Core(项目A)的页面
但是
这不起作用http://10.XX.XX.XX:81/api/facultyinterestitems 并且不显示另一个正在运行的 .net 核心项目(项目 B)的页面,而是显示错误页面
无法访问此站点连接已重置。
这是项目 B 上的 LaunchSettings.json
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://10.XX.XX.XX:53199",
"sslPort": 44378
} },
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/FacultyInterestItems",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"FacultyAPI": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/FacultyInterestItems",
"applicationUrl": "http://10.XX.XX.XX:5050",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
} } }
和项目 B 的 Program.cs
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>().UseUrls("http://10.XX.X.XX:5050") ;
}
请帮忙
【问题讨论】:
标签: nginx asp.net-core webserver port config