【发布时间】:2023-03-21 16:35:01
【问题描述】:
我在 nginx 反向代理后面有一个 nuxt.js 应用程序。 nginx conf 文件如下所示:
server {
listen 80;
# Match *.lvh.me
server_name ~^(?<user>.+)\.lvh\.me$;
location / {
proxy_pass http://localhost:8080/sites/$user$uri$is_args$args;
}
location ~* \.(?:js|css|jpg|jpeg|gif|png|ico|cur|svg)$ {
proxy_pass http://localhost:8080;
}
}
如您所见,我将所有站点子域映射到站点上的特定路径,并且运行良好。我还在映射要从根加载的所有资产(因为否则会引发 404 错误)。
我面临的唯一问题是,每当我访问子域 e.g subdomain.lvh.me 时,它会加载两个相互重叠的页面,来自子域根目录的原始页面(这是预期的)以及来自主域根目录的页面i.e. lvh.me(这不是预期的)。
您能否检查一下我的 conf 文件,看看我在这里做错了什么?
【问题讨论】:
标签: vue.js nginx reverse-proxy nuxt.js