Centos7下使用Nginx部署.NetCore项目

1年前 (2024-02-09)阅读52回复0
administrator
administrator
  • 管理员
  • 注册排名1
  • 经验值775
  • 级别管理员
  • 主题155
  • 回复0
楼主


链接来自:https://www.cnblogs.com/jiangcong/p/13793039.html


本篇博客只介绍最简单的Nginx配置NetCore项目,不涉及负载均衡配置,负载均衡配置我会抽空另写一篇博客!

 

1.首先发布.NetCore项目到服务器上,并运行程序。根据项目需要可自行设置自启动,详细请见 Centos7下设置.NetCore程序自动启动

2.修改Nginx配置,关键配置代码如下:

复制代码
server {
        listen       80;
        server_name  localhost;

        location / {
        proxy_pass http://localhost:5000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection keep-alive;
                proxy_set_header Host $http_host;
                proxy_cache_bypass $http_upgrade;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
复制代码

3.重新加载nginx配置文件

cd /usr/local/nginx/sbin/./nginx -s reload


0
回帖

Centos7下使用Nginx部署.NetCore项目 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息