Configure Docker to use a proxy server

Well all my ‘problems’ and questions are handled good! Thank you guys for any reply that helped me a lot. I got serveral Wordpress containers with all there own stuff, databases can only get access from localhost and I got NextCloud running in container with all configurations good and like I wanted, even with two-step verification as well…

Nou I want to use https://docs.docker.com/network/proxy/ to set domain names to IP:Poort and I would like you advise how this works.

PLEASE READ COMMENTS IN CODE BELOW

{
 "proxies":
 {
   "default": #what does they mean with default? I have serveral websites, what should I do?
   {
 "httpProxy": "http://127.0.0.1:3001", # let's say this is one website
 "httpsProxy": "http://127.0.0.1:3001", # I think this is the same, but secure
 "noProxy": "*.test.example.com,.example2.com" # are this the domain names that point to IP above?
   }
 }
}

And what do I have to do with this .json file if I have websites like this:
website one http://120.120.120.120:8080
website two http://120.120.120.120:8000
website three http://120.120.120.120:8088 etc etc

{
 "proxies":
 {
   "default":
   {
 "httpProxy": "http://120.120.120.120:8080", 
 "httpsProxy": "http://120.120.120.120:8080", 
 "noProxy": "domain1.com" 
   }
   {
 "httpProxy": "http://120.120.120.120:8000", 
 "httpsProxy": "http://120.120.120.120:8000", 
 "noProxy": "domain2.com" 
   }
   {
 "httpProxy": "http://120.120.120.120:8088", 
 "httpsProxy": "http://120.120.120.120:8088", 
 "noProxy": "domain3.com" 
   }
 }
}

Do I understand it correct?

(Think) what you describe is a reverse proxy, as in a single entrypoint that routes traffic to the target backends based on ip:port, domain name and port or url path.

Though, the link is about a forward proxy, which is typicaly found in enterprise environments, where direct internet access is prohibited and traffic to the internet needs to send thru a foward proxy (typical a http proxy) instead.

I am quite sure you will find many post regarding reverse proxies. You can either use something like Traefik (highly recommended!) or jwilder’s nginx-proxy where routing is configured using labels on target containers or use nginx/apache to manualy maintain your reverse proxy rules. Make sure the domain names you want to use are known by your dns server. Without working name resolution it is worth nothing if a reverse proxy is listening on a domain name, but the client is not able to resolve it…

1 Like