vite nginx 反向代理
export default { server: { host: 'my-custom-domain.local', port: 3000, hmr: { host: 'my-custom-domain.local' } } }
cd /usr/local/nginx/conf/vhost/file.conf
server { listen 80; server_name my-custom-domain.local; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
restart nginx
nohup npm run dev > vite.log 2>&1 &
nohup 命令是一个 Unix/Linux 命令,它的作用是忽略挂起(SIGHUP)信号,使得进程在用户退出会话或关闭终端后依然能够继续运行。nohup 的全称是 “no hang up”。
nohup:忽略挂起(SIGHUP)信号,使命令在退出终端后继续运行。
npm run dev:启动 Vite 开发服务器。
> vite.log:将标准输出重定向到 vite.log 文件。
2>&1:将标准错误重定向到标准输出。
&:在后台运行该命令。