码迷,mamicode.com
首页 > Web开发 > 详细

阿里云 asp.net core nginx 单机部署

时间:2018-08-17 22:24:30      阅读:308      评论:0      收藏:0      [点我收藏+]

标签:weex   www.   nginx 配置   clu   start   prot   root   restart   The   

1. dotnet core 安装 https://www.microsoft.com/net/download#core 
安装之前要安装依赖:yum install libunwind libicu

2.nginx 安装 
yum install nginx 
systemctl start nginx 
3. dotnet 后台运行 
startup 文件增加: 
app.UseForwardedHeaders(new ForwardedHeadersOptions 

ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto 
}); 
使用supervisor 启动 
https://www.cnblogs.com/ants/p/5732337.html#_label6 
在这个目录下:/etc/supervisor/conf.d

supervisorctl stop all 关闭所有应用 
supervisorctl reload 重新加载配置 
supervisorctl start all 启动所有应用 
supervisord -c /etc/supervisor/supervisord.conf 
有时候会出问题,需要手动kill掉进程 
ps -ef | grep supervisor 查看有几个进程 
netstat -lnp |grep 5001 查看占用5001 端口的进程 
kill -9 xxxx 手动杀掉进程 
4. 配置代理

server { 
listen 80; 
server_name example.com *.example.com; 
location / { 
proxy_pass http://localhost:5001
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; 

}

最终nginx 配置如下:

server {
    listen       443;
    listen       [::]:443;
    server_name  agent.bdvip.net agent.bdvip01.com;
    ssl on;  
    ssl_certificate      /etc/nginx/ssl/bdvip.crt;  
    ssl_certificate_key  /etc/nginx/ssl/bdvip.key;
    ssl_session_cache    shared:SSL:1m;  
    ssl_session_timeout  5m;  
    ssl_ciphers  HIGH:!aNULL:!MD5;  
    ssl_prefer_server_ciphers  on;  
    #root         /usr/share/nginx/html;
    # Load configuration files for the default server block.
    #include /etc/nginx/default.d/*.conf;

    location / {
     proxy_pass         http://localhost:5001;
     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;
    }
    ##weex 目录
    location /weex/ {
        root /var/www/;
        ##过期时间单位天
        expires 7d;
    }
    location ~^/favicon\.ico$ {
        root   /var/www/;
    }
    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

在/etc/nginx 目录下 
nginx 命令 
service nginx restart 
/etc/init.d/nginx stop 
/etc/init.d/nginx start

阿里云 asp.net core nginx 单机部署

标签:weex   www.   nginx 配置   clu   start   prot   root   restart   The   

原文地址:https://www.cnblogs.com/chenzhe/p/9495312.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!