nginx反向代理vue时提示Invalid Host header

现象:

nginx反向代理vue项目,提示Invalid Host header。

原因:

出于安全考虑,默认检查hostname,如果hostname不是配置内的就不能访问。

解决办法:

添加disableHostCheck: true,跳过检查。

举例:

在vue.config.js中,修改配置:disableHostCheck: true,

module.exports = {
    devServer: {
        open: true,
        host:"batman.com",
        port: 8082,
        https: false,
        disableHostCheck: true,
       ...   
    },
    ...
}
原文地址:https://www.cnblogs.com/John-2011/p/14863313.html