Selfhosting with docker on VPS with reverse proxy and docker networks. #7351
eyduh
started this conversation in
Show and tell
Replies: 1 comment
-
This is awesome! Thanks for contributing! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
intro:
I have a budibase instance running on a VPS where i run everything in docker containers. I prefer to keep all the ports locked down except for the ones that my reverse proxy use.
To do this, I use the very handy docker networks feature so that I can resolve various microservices using their containers names.
With a docker-compose.yml setup, everything in that cluster get added to the same network automagically, but what if I want to be able to restart the flat file CMS that I use for the front page without having the budibase instance go down? Enter docker networks!
how to:
To use this feature I first create an "external" docker network.
docker network create reverse-proxy
I call my network reverse-proxy because I use the same network for all services, however if you want a slightly more secure setup you can make one network for each service and add the reverse proxy to every network.
After you've made your docker network you simply add the following two sections line to all your docker-compose files:
to each "service" section
and
to the bottom of all the docker-compose.yml files.
When you have done this you can comment out the
ports:
section on all the services, in the case of budibase that\s only on the bbproxy container.A modified budibase docker-compose.yml would look like this:
reverse proxying
For reverse proxying with docker networks you need to add the reverse proxy to the same docker network.
npm
I often use nginx proxy manager, set up like so:
Settings would be like so:
Note the use of http here, I tried with https as well but it wouldnt work. This this does not really matter as the unencrypted traffic is on the local docker network and not on an actual network.
Note:
the line
- '10.6.0.1:81:81'
is mapping the web interface of nginx proxy manager to the ip address of the wireguard network I have setup on the VPS. If you have a different setup this mapping would be different. Alternatively, you can map it to 127.0.0.1 and use ssh tunnelling to access it on your local machine.ssh -L 127.0.0.1:81:[vps.vpn.ipv4.address]:81 user@[vps.vpn.ipv4.address]
. Another way would be to comment this line out except for when you want to change the settings, then re-comment when done.caddy
alternatively, you can use caddy for reverse proxying, the project below adds the ability to use docker container names to caddy reverse proxy:
in your caddy file, swap out
localhost:10000
withbbproxy:10000
This will keep your setup slightly more secure by only having the necessary ports open to the outside world.
Enjoy!
Beta Was this translation helpful? Give feedback.
All reactions