Nginx+vue+net6(API)
windows上的部署
下载nginx
打包vue
发布net6 (我打包的是无需环境的独立文件)
打开执行文件,默认http://localhost:5000
解压得到nginx文件夹,进入conf 找到nginx.conf
修改为如下代码
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://127.0.0.1:5000;
root html;
index index.html index.htm;
}
}
server{
listen 8080;
server_name localhost;
location / {
root D:/nginx-1.22.1/html/web;#vue build目录
index index.html;
try_files $uri $uri/ /index.html;
}
location /UploadFile/ {
alias D:/DownLoad/;#静态文件等其他
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
location /apiv1/ {
proxy_pass http://127.0.0.1:5000; #后台API
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
OK,这样就完成了
评论 (0)