0

This HAProxy configuration should serve:

  • the Google main web page when asking http://localhost:9000/google/
  • the Wikipedia main web page when asking for anything else hitting http://localhost:9000

I am not sure what's wrong with configuration file for HAProxy. I've tried to make HAProxy log everything to stdout (check the configuration details below), but when hitting anything served by localhost:9000 I don't see log lines (docker logs -f ...), also: I always get back 503 Service Unavailable.

It might be the problem is docker itself, but I can not find a way to troubleshoot/debug this setup.

  • Why the reverse-proxy rules don't work? I am not able to see either www.google.com or www.wikipedia.org? How to fix this?
  • Why HAProxy is not logging anything on stdout? How to fix this?

The HAProxy config file:

global
    log 127.0.0.1 local0 debug

defaults
    log     global
    mode    http

    timeout connect 3000
    timeout client  3000
    timeout server  3000

frontend reverse_proxy_routing_thing
    bind *:9000
    option tcplog

    acl path_google  path_beg /google/
    use_backend backend_google if path_google

    default_backend default_backend_wikipedia

backend default_backend_wikipedia
    server my_default_backend_wikipedia www.wikipedia.org

backend backend_google
    server my_backend_google www.google.com

The docker file called Dockerfile.reverse-proxy:

FROM haproxy:1.8.14-alpine

COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
  • I build the docker image like this: docker build -t rev-proxy-test-i -f Dockerfile.reverse-proxy .
  • I run the docker container like this (cf. the port mapping): docker run -d --name rev-proxy-test-c -p 9000:9000 rev-proxy-test-i
TPPZ
  • 101
  • 2
  • Well, did you test this outside the container prior to dockerizing it ? – drookie Dec 06 '18 at 17:16
  • No I am trying to keep my machine clean/decoupled from "random packages" I am not familiar with e.g. HAProxy. I could try to setup a VM with Vagrant, then do what you asked in there, but I need to find the time to do that. – TPPZ Dec 06 '18 at 17:21

0 Answers0