Centos7下使用Nginx部署.NetCore项目

本篇博客只介绍最简单的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

 

posted @ 2020-10-10 16:37  JcongJason  阅读(363)  评论(0编辑  收藏  举报