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.
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).
Related
I am trying to implement LetsEncrypt on Spring Boot app. I am using docker to deploy, I am creating a docker image locally, pushing it to docker hub and then running it in Ubuntu using this docker command docker run -d -p 80:80 myapp:latest and this is just http so now I am trying to use LetsEncrypt but I don’t know how to do it. Any help or any direction towards some links would be highly appreciated. Thanks
Architecture: need for a reverse proxy + a container orchestration tool
If your Spring-Boot container serves HTTP-only requests, you can link it with a TLS termination proxy, which will accept incoming TLS connections and forward requests to your container.
Many implementations of reverse proxys are available, which can play this role of TLS termination proxy (see this paragraph on Wikipedia), using e.g. Let's Encrypt as you suggest.
Most of these implementations are also available as Docker images, so you may want to rely on a container orchestration tool such as docker-compose along with a docker-compose.yml to create a private network for the two containers to communicate (or, use a more involved orchestration solution such as Kubernetes).
Overview of several Docker implementations
To give a few examples of Docker images that implement this, you could for instance use one of these popular reverse proxys (the first two being mentioned in Gitea's doc):
NGINX (also bundled in projects like https-portal to automate the certificate generation),
Apache2 httpd,
Træfik, which additionally provides a "monitoring dashboard" as a webapp (see also the official doc that gives many details on automatic certificate generation)
If you want to keep things simple (keeping 1 container only with the Spring-Boot app, without a sidecar), you can use the library LetsEncrypt Spring-Boot helper. It allows embedded Tomcat on Spring-Boot to obtain LetsEncrypt certificate and renew it automatically.
As the key advantage of it - it is native Java + Spring-Boot, so no sidecars are necessary, just embed the library, expose ports 80 and 443 and everything else will be done automatically.
The reason I've created it is that all those sidecars just add unnecessary configuration complexity to the application. For simple pet-projects such added complexity is not justified. Embedded Tomcat from Spring-Boot is more than enough for these kind of projects
I have a Spring-Boot Application with REST API (Maven build and MongoDB Database). I will also make a UI with Angular 2 on top of that (npm build).
What i would like to do is, to host this site, with its backend & database on a server. Can i do that on my Synology NAS (DS216j)? Or should i better buy a small computer like Raspberry Pi 3?
I have heard somewhere that we can deploy our apps in Docker, and Synology has a docker app or sth? Will this help me reaching my goal? I would like to have a step by step guide from your similar setups.
As far as I understand, you only want to get your app running on your NAS, so using Docker would be an option, but no requirement.
According to the model-specific download page, your DS216j supports Java8.
So what you have to do:
Install Java on your NAS
Package your application as standalone jar-file: If not yet done, you can do that in your pom.xml (see Spring Boot documentation for details; btw, this standalone mode is one of the best features of Spring Boot)
Now you can upload the jar-file
Run it via the command line with java -jar <jar-file-name>.jar
Just make sure that the port of your app does not conflict with the ports used by your NAS.
You could also create a Docker image from your app and run it on your NAS, it seems like your model supports Docker: https://www.synology.com/en-us/dsm/packages/Docker. But that would create some extra effort, but no added value, from my point of view.
I have a file containing privileged information (private/public keys, etc) which I don't want to commit to my github repository but is required to run my data processing app. I'm using elastic beanstalk to deploy this application as a docker container to an EC2 instance.
Trying to stay away from hacking something together with environment variables. I've seen that using a separate data container and attached data volume might be the proper way to do this. I haven't been able to get this working properly at this point. I'm also considering using etcd (https://coreos.com/blog/etcd-2.2/).
Interested in knowing how other developers are going about this task.
I forked existed docker image, included special path in every config that my app was needed. Or I create /some_dir inside docker container and create links to those dir. For example:
/etc/apache2 ---> /some_dir/apache2/
I run docker container with external volume. You can read about this "Managing data in containers":
docker run --rm=true -ti -v `pwd`:/some_privileged_imformation_path my-docker-hub-user/docker-image:${OS_TYPE}${OS_VERSION}_${TAG} myapp
Also I am using https://hub.docker.com/ for free to do automate build of containers on GitHUB.
I have a regular netty application server that runs on port 44080 and is built as a .jar file. I would like to use elastic beanstalk to manage the lifecycle of the application. Is there a way I can deploy the jar or something similar using elastic beanstalk?
It seems netty is currently not supported by elastic beanstalk. If your application can also run on Tomcat, you could do that - with Tomcat, you just need to enter some basic settings in the webinterface and you´ll get a fully working environment where you can upload jar files to.
If you need netty as a platform, you could try using Amazon OpsWorks. I never worked with it myself, but I know you can create your own "environment configurations" there. You´d basically create a few scripts to setup your server and deploy your application and OpsWorks lets you execute those through the web ui and also provides capabilites for auto-scaling, failover, etc. in OpsWorks environments.
There's nothing wrong about using Netty. In fact, one of our archetypes for AWS Elastic Beanstalk contains support for Dropwizard (by using Docker as its stack), thus not being dependent on a Java Web Container.
$ mvn archetype:generate -Dfilter=elasticbeanstalk-docker-dropwizard
It might need a few tweaks, but the overall idea is to package all your dependencies into a zip file and deploy it. Also, make sure your Dockerfile EXPOSEs port 44080.
I have WAMP installed on my local machine and am looking to serve up charts using jFree's Eastwood charting, which requires me to use servlets. So basically I will insert images with src tags that have URLs pointing to my servlet on the same machine.
What's the easiest way to enable servlets on the same machine? Do I need to install a servlet server on a different port? Or is there a way to integrate it into WAMP?
You have a couple of choices.
The easiest is to get a Web container such as Tomcat or Jetty and run it on a different port (by default it's usually 8080).
A Web container can be integrated into Apache and this tends to be what happens in production sites. See Tomcat-Apache HOWTO or Apache 2 with Tomcat 6: How to Configure. It's probably overkill for a local install.