0

What am I trying to achieve -> I'd like to use my locally run application through docker container.

I created an apache proxy running in docker container. proxy (docker container) -> localhost application (on physical host)

When I direct my browser to docker_ip:8001, the apache instance is running, but it can't proxy the host localhost.

Configuration is as follows:

<Location /test/auth>
    SSLRequireSSL
    SSLVerifyClient optional
    SSLVerifyDepth 3
    SSLOptions +ExportCertData +StdEnvVars

    RewriteEngine on
    RewriteCond %{SSL:SSL_CLIENT_VERIFY} !^SUCCESS$
    RewriteRule .* /test/fail [L]
</Location>

RequestHeader set HTTPS "%{HTTPS}s" env=HTTPS
...


ProxyPass               /test   http://host:8080/test retry=0
ProxyPassReverse        /test       http://host:8080/test

I have an application running on wildfly @ http://localhost:8080/test (host machine)

The expected behaviour is that I go to docker_ip:8001/test and I can use the application running at http://localhost:8080/test.

This does not work for me and nor the other similar questions. eth0 ip is pingable, but when I do wget I get connection refused.

So I tried running

docker run --add-host=host:192.168.xxx.xxx -p 8001:443 -it docker-test bash

now pinging and wget against host worked well and it received a response from an apache I'm running on host. How can I replace 192.168.xxx.xxx with localhost?

*Note: using win7, but this should not really matter?

Noripsni
  • 425
  • 1
  • 5
  • 21
  • 1
    Does it actually need to be `localhost` and not the hosts IP? This won't ever work because Docker is running as a virtual machine on Windows. The `localhost` will be the container. Then, even if you run in bridged or host mode networking, `localhost` will then just be the virtual machine. Neither are the actual Windows host. – Andy Shinn Jun 26 '17 at 17:57
  • It would be best if it would work this way. The problem I'm solving is that in CI and live environment, we have an apache proxy for authentication logic and apply aggregation. And to get the same logic for development environment I thought it would be reasonable to define a docker container that every developer can run on their machines. I can use the hosts IP, but then it has to be configured for every type of server separately and it adds unnecessary complexity. Maybe docker is not a good solution for this kind of problem or I am using it wrong. – Noripsni Jun 26 '17 at 18:56
  • Generally, both would be running as containers and share a "Docker network" so this wouldn't be a problem. However, the host itself also has a NAT gateway for Docker that is _usually_ 172.17.42.1. You could try that as a default. Next, you could probably template out this configuration using something like envsubst or confd and have a default environment variable that can be changed. Then, when starting the container, if the host IP happens to be different, you can just set `-e HOST_IP=` or similar. Though, this is probably a separate question. – Andy Shinn Jun 26 '17 at 23:27

0 Answers0