【发布时间】:2018-07-27 21:14:42
【问题描述】:
所以我的情况如下 - 我有两个捆绑的 Angular 应用程序,位于 Docker 容器内。我想使用相同的 nginx 配置将它们托管在单独的子域(app1.example.com 和 app2.example.com,或者现在是 app1.localhost:8000 和 app2.localhost:8000)。
目前我正在捆绑它们并将它们粘贴在单独的目录中,
COPY --from=web-build-stage /app/dist/first-app/ /usr/share/nginx/html/first
COPY --from=web-build-stage /app/dist/second-app/ /usr/share/nginx/html/second
我的 nginx 配置被分成如下两台服务器 -
server {
listen 80;
server_name first.localhost;
location / {
root /usr/share/nginx/html/first
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
server {
listen 80;
server_name second.localhost;
location / {
root /usr/share/nginx/html/second
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
我也更新了我的主机文件 -
127.0.0.1 localhost
127.0.0.1 first.localhost
127.0.0.1 second.localhost
对于我的一生,我无法弄清楚为什么它没有正确代理或者我在哪里出错了配置。
有什么见解吗?
【问题讨论】:
标签: angular docker nginx devops