找到nginx安装目录下的conf文件夹下的nginx文件
server {
listen 80;
#请求页面的url地址
server_name a.nuxt.com;
location / {
root html;
index index.html index.htm;
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;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Nginx-Proxy true;
proxy_cache_bypass $http_upgrade;
proxy_pass http://10.12.0.156:3000; #反向代理
}
配置http下的server下的location下的proxy_pass成你的项目地址
然后重启nginx这样就能在localhost:80访问项目了