来自docker-compose XXX:443的端口转发

时间:2018-01-08 16:14:16

标签: python nginx docker-compose

我拥有一个python + uwsgi + nginx应用程序。 我可以通过这个docker-compose文件启动这个应用程序:     版本:' 3.4'

services:    
   backend:
      restart: always
      image: backend:0.1
      depends_on:
       - db
      expose:
       - 5001
      volumes:
       - share_vol_lab:/home/ubuntu/data

   frontend:
      restart: always
      image: frontend:1.1
      depends_on:
       - backend
      ports:
       - 443:443

   db:
      restart: always
      image: postgres:1.1
      environment:
      expose:
       - 5432
      volumes:
       - data_lab:/var/lib/postgresql/data

volumes:
   data_lab: {}
   share_vol_lab: {}

一切都在接受,这意味着我可以访问网址:

  

的https:// 主机IP /登录

我想在同一台主机上再运行我的应用程序,以充当不同的环境。 我将docker-compose文件复制到不同的文件夹更改前端端口443:443到444:443,以防止端口冲突,在浏览器中:

  

的https:// 主机IP :444 /登录

并且第一页(静态html)确实已成功加载。 当我尝试登录时,请求应该从nginx反向代理到后端服务,但根本没有响应。 这是nginx conf:

server {
  listen  80;
  charset utf-8;
  location / {
    rewrite ^ https://$host$request_uri? permanent;
  }
}

server {
  listen        443 ssl;
  error_page 497 301 =307 https://$host/login; 
  root /usr/share/nginx/html;
  charset utf-8;
  location ~ ^/(scripts.*js|styles|images) {
    gzip_static on;
    expires 1y;
    add_header Cache-Control public;
    add_header ETag "";
    break;
  }
  location / {
    try_files $uri /index.html;
  }
  location /api/v1 {
    include         uwsgi_params;
    uwsgi_pass backend:5001;
    uwsgi_read_timeout 60s;
    uwsgi_send_timeout 60s;
    uwsgi_connect_timeout 60s;
  }
}

和我的uwsgi.ini:

[uwsgi]
module = app.api:app
processes = 5
master = true
socket = :5001
protocol = uwsgi
lazy-apps = true
harakiri = 30

希望得到你们的任何帮助,谢谢!

0 个答案:

没有答案
相关问题