简体   繁体   中英

Run apache in both host machine and docker container on 80 port

I need to setup something like automated server setup using docker. Now server machine should support both docker or normal setups. So I need to setup apache web server on both docker container and host machine on 80 port. Like

Host Machine  : application1.serverhost.com
Docker Machine  : application2.serverdocker.com

But Docker will not utilize 80 port as it is already bind on host machine apache. While I am thinking of use reverse proxy on host machine with apache like

Proxy Setting -> 172.17.0.2:8080 

while on browser connect to proxy application2.serverdocker.com on 80 port. IP -> 172.17.0.2 is docker container IP which I am thinking to get from docker inspect.

But if any other way to handle this in docker itself where I can ignore reverse proxy on host machine. And call both application1.serverhost.com and application2.serverdocker.com from browser without appending port.

EDIT : One big issue using reverse proxy is that whenever I need to add another docker on same server I need to add also proxy for that new IP too as that would also running docker apache on other port like 8081 than Host port:80 and first docker's port:8080. In other words lot of reverse proxy settings and ports in case of lot of docker instances.

If you are using a reverse proxy, (like an NGiNX) , that means both your Apache servers must run on ports different from 80.

Only your NGiNX would run (on host directly for instance) on port 80, and would redirect to localhost_apache1:xxx and 172.17.0.2_apache2:yyy .

From the user perspective, both Apache would be seen "as if" they were running on port 80 themselves.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM