0

I currently have a VM running nginx, UFW, and let’s Encrypt to force all traffic over https to multiple websites in my network. I’m starting to “dockerize” some of my services (not all of them), and wanted to try getting nginx running in a container.

There were a lot of steps to get my nginx VM working. I had to install UFW, nginx, Let’s Encrypt (with certbot). I had to configure UFW, add server blocks for nginx, create symbolic links, run nginx commands, run Let’s Encrypt commands, etc.

It looks like a lot of people use the proxy companion, but I’m not sure if that only sets up nginx to work with services running in a docker container. Is it possible to use the companion to reverse proxy traffic for a subdomain to an internal http://172.16.68.99:6666 in addition to pointing to docker containers?

ETA: I just realized, for those services that aren’t in containers, would it be possible to create an Apache container to redirect to my non-container service, or would that break the proxy?

WhiskerBiscuit
  • 4,795
  • 8
  • 62
  • 100

1 Answers1

1

Yes, it's possible. The default bridge networking setup can't connect to services on the host network by default. You need to look into an alternate networking setup so that your nginx docker container can proxy to other services. Would recommend reading this: https://docs.docker.com/network/#network-drivers

Also it seems like you might be able to get away with simply using the --network host option, to share the same host network all your services are already running on: From inside of a Docker container, how do I connect to the localhost of the machine?

maxm
  • 3,412
  • 1
  • 19
  • 27
  • does [this make sense](https://github.com/CWempe/nginx-proxy/tree/upstream_name#non-docker-host)? – WhiskerBiscuit Oct 07 '18 at 19:01
  • not sure, but from a cursory look I think that just helps you manage new containers and their routing rules in nginx. I think you still need to solve the problem of routing to your other servers. if your servers have static ip addresses you could try and route to those ips directly – maxm Oct 07 '18 at 19:14
  • also sorry my answer is wrong, you can route nginx to your servers, provided they are accessible within the network docker is running in. – maxm Oct 07 '18 at 19:16
  • the setup should actually be quite simple, would start dockerizing and just see what kind of snags you hit. apologies for the initial misinformation, I was confusing this with an unrelated networking problem – maxm Oct 07 '18 at 19:17