Issue
I use nginx reverse proxy with docker and want to automate my nginx configuration. For example, I want to tell my java app a domain/server_name (e.g. myapp.example.com) and a backend system. And my java app should tell nginx to configure that.
Is this possible or is there an alternative reverse proxy software with that functionality.
Solution
One way to achieve that would be to use a shared volume that both containers (the java container and the nginx container) can access and where the nginx configuration file is placed. This would also work if java is not in docker then it just needs access to the mapped folder.
Whenever you want to update the config just rewrite it and then trigger nginx to reload. There are mutliple ways to achieve this. Most easily by using
docker exec nginx-container-name nginx -s reload
e.g. via Java ProcessBuilder or the awesome Java Docker Project https://github.com/docker-java/docker-java.
Note: If you run java inside a docker container you have to map the docker socket inside the container (e.g. using -v /var/run/docker.sock:/var/run/docker.sock
from shell).
Answered By - Julian Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.