实体机ubuntu下,nginx增加代理一个网页
一、新增配置文件夹
cd /etc/nginx
sudo mkdir configs
sudo touch configs/ad_hmi.conf
ad_hmi.conf内容如下
server {
listen 8999; # 自己设置端口号
server_name 127.0.0.1; # 自己设置ip地址 ip!
#access_log logs/host.access.log main;
location / {
root /home/chenjian/Downloads/dist; # 这里写项目打包好的dist文件的地址,可以改,这个随意
index index.html; # 需要保证dist中有index.html文件
try_files $uri $uri/ @router;
}
location @router {
rewrite ^.*$ /index.html last; # 解决重新刷新页面,页面空白的问题
}
error_page 500 502 503 504 /50x.html; #错误页面
}
在nginx配置文件的指定位置中包含新增的配置文件,(大致位置在http{}中)
sudo vim /etc/nginx/nginx.conf
include /etc/nginx/configs/*.conf;

重启nginx
sudo systemctl restart nginx.service

浙公网安备 33010602011771号