Haproxy未绑定到Ubuntu Server 18.04上的前端

时间:2019-02-12 10:52:44

标签: docker-compose haproxy

如何解决Haproxy无法在ubuntu服务器上运行的问题,我是否缺少某些内容,请在此处提供指南。

下面,我在本地macbook docker上没有问题,

stm-haproxy    | listen stats
lstm-haproxy    |   bind :1936
lstm-haproxy    |   mode http
lstm-haproxy    |   stats enable
lstm-haproxy    |   timeout connect 10s
lstm-haproxy    |   timeout client 1m
lstm-haproxy    |   timeout server 1m
lstm-haproxy    |   stats hide-version
lstm-haproxy    |   stats realm Haproxy\ Statistics
lstm-haproxy    |   stats uri /
lstm-haproxy    |   stats auth stats:stats
lstm-haproxy    | frontend default_port_80
lstm-haproxy    |   bind :80
lstm-haproxy    |   reqadd X-Forwarded-Proto:\ http
lstm-haproxy    |   maxconn 4096
lstm-haproxy    |   default_backend default_service
lstm-haproxy    | backend default_service
lstm-haproxy    |   server lstm_lstm_1 lstm_lstm_1:8008 check inter 2000 rise 2 fall 3
lstm-haproxy    |   server lstm_lstm_2 lstm_lstm_2:8008 check inter 2000 rise 2 fall 3
lstm-haproxy    | INFO:haproxy:Config check passed
lstm-haproxy    | INFO:haproxy:Reloading HAProxy
lstm-haproxy    | INFO:haproxy:Restarting HAProxy gracefully
lstm-haproxy    | INFO:haproxy:HAProxy is reloading (new PID: 11)
lstm-haproxy    | INFO:haproxy:===========END===========

但是当我推送到临时服务器时,ubuntu服务器18.04

lstm-haproxy    | listen stats
lstm-haproxy    |   bind :1936
lstm-haproxy    |   mode http
lstm-haproxy    |   stats enable
lstm-haproxy    |   timeout connect 10s
lstm-haproxy    |   timeout client 1m
lstm-haproxy    |   timeout server 1m
lstm-haproxy    |   stats hide-version
lstm-haproxy    |   stats realm Haproxy\ Statistics
lstm-haproxy    |   stats uri /
lstm-haproxy    |   stats auth stats:stats
lstm-haproxy    | INFO:haproxy:Launching HAProxy
lstm-haproxy    | INFO:haproxy:HAProxy has been launched(PID: 9)

我在MacBook上的docker和docker-compose版本,

Docker version 18.09.1, build 4c52b90
docker-compose version 1.23.2, build 1110ad01

我在ubuntu服务器上的docker和docker-compose版本,

Docker version 18.09.1, build 4c52b90
docker-compose version 1.23.1, build b02f1306

这是我的docker-compose.yml

version: '3'

services:
  lstm:
    restart: always
    build:
      context: .
    environment:
      MAX_REQUEST: 100
      NUM_WORKER: 5
      BIND_ADDR: 0.0.0.0:8008
    command: bash monkey-sync.sh
  lstm-haproxy:
    image: dockercloud/haproxy
    links:
      - lstm
    ports:
      - '8008:80'
    container_name: lstm-haproxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

这是我的dockerfile,

FROM python:3.6.1 AS base

RUN pip3 install blablabla

WORKDIR /app

COPY . /app

RUN echo

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

EXPOSE 8008

任何向导对我都有很大帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

解决了!需要在lstm环境中设置SERVICE_PORTS: 8008