nginx-reverse-proxy - 通过 nginx 暴露多个 docker 服务
问题描述
我正在使用 nginx 为一个由 docker 容器生成的网站提供服务,该网站也位于 docker 容器中。这个设置工作得很好。
我现在想做的是从多个容器为多个网站提供服务。
我的(简化的)设置如下。
http {
upstream app_01 {
server container_01:80;
}
upstream app_02 {
server container_02:80;
}
server {
listen 443 ssl;
include common.conf;
include /etc/nginx/ssl.conf;
location / {
proxy_pass http://app_01;
proxy_redirect off;
include common_location.conf;
}
location /alternative {
proxy_pass http://app_02;
proxy_redirect off;
include common_location.conf;
}
}
}
common_location.conf
包含:
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_set_header Host $host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Port $server_port;
我原来的网站仍然可以正常工作(container_01),我可以访问第二个网站(container_02);起始页面被部分加载。它似乎保留了upload/
所有链接中的部分。
我的问题:我如何让它工作?
解决方案
由于似乎没有人能够回答,我最终使用了 nginx 的替代品,它在十分钟内就可以工作。
推荐阅读
- powerbi - DAX 问题 - 无法使用计算将多列转换为标量值错误
- python - 删除重复行并保留非零列中的值
- tensorflow - 对 tensorflow lite 层进行更改
- reactjs - 如何自定义 AWS Amplify 中的内置身份验证组件(特别是“aws-amplify-react”库)?
- php - 在 mysql json 列中搜索以检查同一对象索引上的多个条件
- python - python找到可以与多处理一起使用的lru_cache替代方案
- powershell - 使用 Powershell CLI 在 azure 中更改日志警报的电子邮件主题
- python - 使用 Tensorflow 2.0 进行一维分类
- flask - 使用 python2 加载 wsgi 模块(pyhton3.6)时的烧瓶导入错误
- linux - 在未将 LD_LIBRARY_PATH 设置为非默认值的情况下运行已编译的应用程序时共享对象文件丢失错误