【netcore基础】CentOS 7.6.1810 搭建.net core 2.1 linux 运行环境 nginx反向代理 supervisor配置自启动

之前写过一篇Ubuntu的环境搭建博客,感觉一些配置大同小异,这里重点记录下 nginx 作为静态 angular 项目文件服务器的配置

参考链接

【netcore基础】ubuntu 16.04 搭建.net core 2.1 linux 运行环境 nginx反向代理 supervisor配置自启动

Nginx配置

muc api接口服务的配置,域名(api.wxsale.gedu.org)转发到5000端口

如下:

    server {
         listen 80;
         server_name api.wxsale.gedu.org;
         root /app/web_root/api.wxsale.gedu.org;
         index index.html  index.htm;
         try_files $uri $uri/ /index.html;
         location / {
             proxy_pass http://127.0.0.1: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;
         }
        error_page 404    /;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
}
        access_log /applog/nginxlog/api.wxsale.gedu.org_access.log main;
        error_log /applog/nginxlog/api.wxsale.gedu.org_error.log;

}

重点是配置域名,端口80指向5000,log日志文件路径

然后是 angular 项目,静态文件转发配置

如下:

    server {
         listen 80;
         server_name wxsale.gedu.org;
         location / {
             root /app/web_root/wxsale.gedu.org;
             index index.html  index.htm;
             try_files $uri $uri/ /index.html;
         }
        error_page 404    /;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
}
        access_log /applog/nginxlog/wxsale.gedu.org_access.log main;
        error_log /applog/nginxlog/wxsale.gedu.org_error.log;

}

配置差不多。

 superior配置

[program:GeduFileServer]
command=dotnet GeduFileServer.dll --server.urls http://localhost:5100
directory=/app/web_root/file.wxsale.gedu.org
environment=ASPNETCORE__ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=5
stderr_logfile=/app/web_root/file.wxsale.gedu.org/logfile/GeduDistributionApi.err.log
stdout_logfile=/app/web_root/file.wxsale.gedu.org/logfile/GeduDistributionApi.out.log

这里可以指定服务端口号,就可以部署多个不同端口的项目了

原文地址:https://www.cnblogs.com/jhli/p/10448304.html