Nginx 安装完成后,创建虚拟站点目录:
# 创建虚拟站点目录
# cd /usr/local/nginx/
# mkdir vhost
# cd vhost/
# vim mysite.conf
这里 ASP.NET Core 的启动地址是:http://localhost:8008
修改 mysite.conf 配置文件内容:
server
{
listen 84;
server_name localhost;
location / {
proxy_pass http://localhost:8008;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host:84;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 1024m; #增加限制的大小,否则稍微大一些的文件报错
}
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
}
修改完成后重新启动 nginx
systemctl restart nginx.service
正文完