Traefik and Apache vhosts - docker

I'm pretty new to docker world and more to Traefik, so maybe I'm asking silly questions.
We have a docker-compose file with a lamp stack and many vhost to route them.
Yesterday I found traefik, and looks good!, but I have so many questions. First is my docker machine has to have more containers than my own pages (for example a thumbor instance), that why I look into traekif, but also I want to have my page1.mydomain.es and page2.mydomain.es and so on.
I can configure Traefik to route to my thumbor container, but the problem is with my Apache sites. How can I route so many domains to the Apache container, and that my Apache understand and give me the right site?
I know that if I make every site a container, I have fixed that, but I don't like. Just think about having 15 sites and every one of them is an Apache container instance drives me nuts.

i answer my self:
labels:
traefik.http.routers.apache.rule: Host(`vhost1.local`,`vhost2.local`)
This makes 2 routes to the same service, traefik send the right header and Apache vhost returns the right site.
But this has some problems for me. With that approach, you can generate some Lets Encrypt certs, but it will give ONE cert with vhost1.local as the main SNI and the rest as a secondary.
To fix that, you need to add as many routes as you want, like this:
labels:
traefik.http.routers.apache1.rule: Host(`vhost1.local`)
traefik.http.routers.apache2.rule: Host(`vhost2.local`)
This will give 2 certs, each with the host as main SNI

Related

Get Visitor IP or a Custom header in Jaeger docker behind docker traefik (v2,x)

we are experimenting with JAEGER as a tracing-tool for our traefik routing environment. We also use an ecapsulated docker network .
The goal is to accumulate requests on our api's per department and also some other monitoring.
We are using traefik 2.8 as a docker service. Also all our services run behind this traefik instance.
We added basic tracing configuration to our .toml file and startet a jaeger-instance, also as docker service. On our websecure endpoint we added forwardedHeaders.insecure = true
Jaeger is working fine, but we only get the docker internal host ip of the service, not the visitor ip from the user accessing a client with the browser or app.
I googled around and I am not sure, but it seems that this is a problem due to our setup and can't be fixed - except by using network="host". But unfortunately thats not an option.
But I want to be sure, so I hope someone here has a tip for us to configure docker/jaeger correctly or knows if it is even possible.
A different tracing tool suggestion (for example like tideways, but more python and wasm and c++ compatible) is also appreciated.
Thanks

GridGain Web Console with Docker: 404 Not Found

I'm trying to deploy GridGain Web Console 2020.03.01 on RHEL7 x86_64 with Docker following documentation here.
However, there is 404 Not Found error on accessing http://localhost:3000/swagger-ui.html page which is used as healthcheck. Backend logs show no errors. The last version I'm able to get containers running with is 2019.12.02 (which in fact refuses to show a connected cluster, but that's another issue). Starting with 2020.01.00, all backend healthchecks fail. That looks suspicious considering that 2020.01.00 releasenotes include updates of io.springfox and swagger-ui-dist.
Besides that, 2020.03.01 releasenotes say that Console's default port is changed to 8008, but the server still starts on 3000.
Anyone had any luck deploying dockerized Web Console?
The Web Console consists of backend and frontend. The backend is started on port 3000 which is printed in log, while the frontend is started indeed on port 8008 - and you most probably want to use this.
The docker-compose.yml given on Documentation site maps container's 8008 port to host's 80 port, feel free to replace with any wanted.
Regarding the heathcheck, /health endpoint is now changed to this
The Swagger was removed in 2020.01.00 due to security concerns (same GG-26726 issue mentioned in the release notes). You are right to be suspicious, I'll ask right people to update release notes and the docs, sorry about the confusion and thanks for pointing the issue out. Swagger was supposed to be an internal feature for Web Console (WC) developer team only.
As you pointed out, starting with 2020.01.00 the Swagger-based health check won't work. Internally, the WC team uses dockerize to wait for backend to start, here's an example from our E2E test suite compose:
entrypoint: dockerize -wait http://backend:3000/health -timeout 2m -wait-retry-interval 5s node ./index.js --target=${TARGET:-on-premise}
This might work for you too, with some adaptation. You will most likely have to remove "healthcheck" sections from docker-compose.yml too, or modify these, if the "http://backend:3000/health" URL can indeed serve as a direct replacement for the old "http://localhost:3000/swagger-ui.html" URL, which I am not sure about.

Serving Multiple Sites via HTTPs using a web-service and Docker

Firstly, this is a great place to learn and share new information.
Now I've an issue with hosting two websites on the same server but before describing my problem, there are some terms that I'll use henceforth to make things easier.
Website Setup
Server OS - CentOS 7 x64, Docker version - 18.03.0-ce, build 0520e24
1st Website: example.com - hosted via Nginx (Runs as a service on the host machine and not via Docker Container) on port 80 (re-directs to 443) : static website with HTML / CSS code.
2nd Website: http://art.example.com:8080/ : served on port 8080 via this Docker Image
SSL - using LetsEncrypt for both the above domains.
Requirements
To serve both sites (and possibly more) via HTTPs without breaking either of them.
This is because when I browse the 2nd website using art.example.com:8080, it works fine but if I browse the 1st website then subsequent requests to 2nd website somehow start going on HTTPs, causing the page to not load.
Questions
Can both sites (and more) be served via port 80|443 via Nginx VHosts (or any other alternative) without using a different port, i.e: 8080 for 2nd website? This is to not have any ports in the URL as mentioned above but just the domain name.
Or, is there a way to forward traffic to the Docker service on a different port while the main main web service listens to port 80|443? What config changes would I need to do?
I've searched on this forum as much possible but couldn't get much.
Please let me know if any more information would be required from me.
Thanks in advance!
Solution: As recommended by this Docker image maintainer - kdelfour as well as a quick recommendation by BretFisher, we can remake the 1st Website as a Docker Container like the 2nd Website and then load-balance them using Traefik as a reverse proxy to manage SSL
Marking this as solved until an even better solution is found, cheers!

Add Certifikate in traefik for Service discovered from rancher

i have successfully configured traefik 1.5.4 to work and talk with rancher.
I'd like to add a few more services to rancher by configuring the services labels.
One service has a different domain (not mine) as the others with a SSL Cert i get from the owner of that domain.
So how do i configure that with Rancher Labels.
I know how to do this in the traefik.toml but im curious if theres a way to configure that without touching the toml file everytime.
Also i think it quite elegant if the services are the owner of their configuration.
Any Ideas ?
Got it,
Label "traefik.frontend.rule" can take multiple Destinaations e.g.
"Host: a.url.cloud,b.url.cloud"

Two Rails apps deployed - How do I change the default App?

I've followed Ryan Bate's guide to deploy two completely different rails apps one one VPS (cost saving, using it for development of small home projects). Link to railscast: http://railscasts.com/episodes/335-deploying-to-a-vps
My issue is: the default application is the one I deployed first, so when I visit the IP address, that is the app which is displayed. How do I configure the server to
Use a subdomain (not sure this is possible using just an IP address)
Change the default app
Had a play around in nginx.conf and read this stack q: NGinx Default public www location?
I can't seem to work it out! Thanks in advance.
I think I understand what you want to do. Your default app term confuses me. Let's throw that out and just say you want to deploy two different rails apps to different domains-- sub or TLD, it doesn't matter. Also, I think you are wanting to deploy them to the same VPS server. Ryan's screencast doesn't include how to do this.
What you are probably looking for is how to host multiple sites (and rails apps) with nginx. Like Ryan's screencast, there are many steps involved to get everything working. I recommend you first focus on domain setup (DNS), then nginx setup. Leaving serving your rails app with unicorn for last.
First
Setup your domain and subdomain to point to the VPS. One way is to create DNS A records point to your VPS IP.
Second
Configure nginx to serve both sites. To get you started in the right direction I recommend you read this: multiple websites on nginx & sites-available. It sounds like you already have nginx serving your app on your domain. So steps might be like:
$ cd /etc/nginx/sites-available/
$ cp default subdomain.example.com
Edit subdomain.example.com accordingly. See nginx docs for details. Also, make sure /sites-available/default and /sites-available/subdomain.example.com are not using _ as server_name directive. Set them to their respective domain names. Also, for now point the root to somewhere that will serve an index.html file (ie. leave rails out of it for now)
$ cd /etc/nginx/sites-enabled/
$ ln -s ../sites-available/eden.jrutherford.com .
$ service nginx restart
If all is well by this point you should be able to visit both domains in a browser and have nginx serve content.
Third
Configure a new unicorn for your subdomain. I'm sorry I don't have specific tips for this step . Follow Ryan's tutorial, search google, unicorn website.
Good Luck.

Resources