NGINX没有路由到网络核心项目(端口不是80)

编程入门 行业动态 更新时间:2024-10-25 14:27:58
本文介绍了NGINX没有路由到网络核心项目(端口不是80)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在/etc/nginx/sites-available文件夹的默认配置文件中包含以下内容

I have the following in the default config file in the /etc/nginx/sites-available folder

server { listen 80; location / { proxy_pass 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 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; } }

此方法 10.XX.XX.XX/并显示该页面 Core(项目A)

this works 10.XX.XX.XX/ and shows the page of Core (Project A)

但是

这不起作用 10.XX.XX.XX:81 /api/facultyinterestitems 并且不显示另一个正在运行的核心项目(项目B)的页面,而是显示一个错误页面

This does not work 10.XX.XX.XX:81/api/facultyinterestitems and does not show the page of another running core project (Project B) instead shows an error page

无法访问此站点连接已重置.

This site can’t be reached The connection was reset.

这是项目B上的LaunchSettings.json

here is the LaunchSettings.json on Project B

{ "$schema": "json.schemastore/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "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": "10.XX.XX.XX:5050", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } }

和项目B的Program.cs

and Program.cs of Project B

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("10.XX.X.XX:5050") ; }

请帮助

推荐答案

无法访问此站点连接已重置.

This site can’t be reached The connection was reset.

此消息显示为b/c,端口81在我的组织中被阻止.

This message was appearing b/c the port 81 was blocked in my organization.

第二,也可以通过在配置文件中使用不同的服务器名称来解决此问题.因此默认文件将变成这样

Secondly, the problem can also be resolved by using different server names in the config file. so the default file will become like this

server { listen 80; server_name keywordsapi.test.kfupm.edu.sa; location / { proxy_pass localhost: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; } } server { listen 80; server_name keywords.test.kfupm.edu.sa; location / { proxy_pass localhost: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; } }

更多推荐

NGINX没有路由到网络核心项目(端口不是80)

本文发布于:2023-11-14 09:07:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   端口   核心   项目   网络

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!