因为热爱,所以分享、因为无知,所以要学。
1. 配置.net core 在Linux运行时环境
2. 准备好nginx环境
注意: 编译的时候有有变化
#切换源码包下 #编译的路径 #ssl
./configure --prefix=/test --with-http_stub_status_module --with-http_ssl_module
3. core 项目发布
4. 把发布目录的文件放到linux服务器上
5. 切换到这个目录,执行启动
# 项目名.dll
#--urls="http://*:8091" 项目发布Ip
#--environment=Development 测试
dotnet 项目.dll --urls="http://*:8091" --environment=Development
启动成功
6. 配置nginx
#配置http跳转https
server{
listen 80 default;
server_name #域名;
# 重点
rewrite ^(.*) https://$server_name$1 permanent;
}
#配置域名
server {
listen 443 ssl;
#域名
server_name 域名;
# 证书目录不需要的https可以直接80 以下的ssl都可以不需要
ssl_certificate #crt文件;
ssl_certificate_key #key文件;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
# 指定密码为openssl支持的格式
ssl_protocols SSLv2 SSLv3 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5; # 密码加密方式
ssl_prefer_server_ciphers on; # 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密
location / {
proxy_pass http://127.0.0.1:8091;
}
7. 启动nginx
#到sbin目录执行
./nginx
如果不出意外直接访问你的域名既可以了,有什么不懂的欢迎留言