appsetting.json
{
"ConnectionStrings": {
"MF.MySQl.ApplicationDB": "zGuqeG3rtm5+bP7XT2PqIc8MNT7U/ZAuSSrrJr/ReZngB1gPt5GRPGHSppS/zBCGufabxLoVs5ZHfxYe3zpxBRx15esc8rSsqgTj8kXUg4WA+s1u4DJW0LzHy3Hd3mwbl1zCa09ucNxlkHmRKYP/aQ=="
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "https://0.0.0.0:5000" // 端口自己改吧
}
}
},
"AllowedHosts": "*"
}
配置服務(asp.net)
配置代碼如下(保存爲xxx.server)
[Unit]
Description=MicroFeel.ids4.server
After=network-online.target
[Service]
Type=simple
User=root
WorkingDirectory=/home/wwwroot
ExecStart=/home/wwwroot/Sugar.IdServer4
Restart=always
[Install]
WantedBy=multi-user.target
在服務器上運行
# xxx就是上面配置代碼的文件名稱
sudo systemctl enable xxx
sudo systemctl start xxx
nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
#設定虛擬主機配置
server {
#偵聽443端口,這個是ssl訪問端口
listen 443;
#定義使用 訪問域名
server_name ids4.microfeel.net;
#定義服務器的默認網站根目錄位置
root /home/wwwroot;
# 這些都是騰訊雲推薦的配置,直接拿來用就行了,只是修改證書的路徑,注意這些路徑是相對於/etc/nginx/nginx.conf文件位置
ssl on;
ssl_certificate /etc/nginx/ids4.microfeel.net_chain.crt;
ssl_certificate_key /etc/nginx/ids4.microfeel.net_key.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照這個協議配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照這個套件配置
ssl_prefer_server_ciphers on;
#默認請求
location / {
proxy_pass http://localhost:5000; #把80端口的訪問反向代理到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;
}
#靜態文件,nginx自己處理
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
#過期30天,靜態文件不怎麼更新,過期可以設大一點,
#如果頻繁更新,則可以設置得小一點。
expires 30d;
}
#禁止訪問 .htxxx 文件
# location ~ /.ht {
# deny all;
#}
}
}
寫在最後
可以通過vs發佈成linxu x64 或者是ram,如果是windows服務器那就生成windows的。這樣可以避免在linux下配置.netcore環境