Тёмный

Nexus with SSL\TLS and Nginx Rev-Proxy over Docker 

ShashankSharmaDevOps
Подписаться 735
Просмотров 9 тыс.
50% 1

Linkedin: / shashanksharma-devops
Twitter: / shankysharma86
GitHub Repo: github.com/sha...
In today's video we will cover the Nexus3 repository with Nginx serving as reverse-proxy to the Nexus and holding SSL certificate. This is one of the famous architecture and yet I have to go through several blogs and technical writeups to get this thing implemented. That gave me a thought that may be i have to come up with a solution which is easier to implement. So this is our architecture and flow where we will spin Nginx, Nexus3 Docker containers. At the front it is going to be nginx container which is holding the SSL certificate to ensure our Nexus3 repo is accessible over secure protocol (HTTPS) and then we will create docker registries, proxy as-well-as hosted. Proxy repo will be backed by Docker, so any pull requests that is being made to Docker proxy registry will further be catered by Docker Hub if requested docker image is missing in Proxy.
Alright, so in summary goal is to spin Nexus repo Docker container with SSL certificates and to implement docker proxy and hosted Registries into Nexus3.
From learning perspective we will learn openssl, generation of self-signed certificates. Now good news is that for step 1,2 & 3 I have prepared an automation for you, but even better news is that we will take a deeper look at the automation so in case you need, you can modify it according to your requirements.
Alright, so switching over to the GitHub repository to take a look at the automation. Here we have NginX folder that contains Dockerfile and nginx.conf file, and then we have scripts folder where we can find the shell scripts and finally the docker compose yaml file.
So lets take a look at the script folder and the nexusnginxproxy shell script. At Line 4 openssl is generating the root key, so here we are assuming that in our system we don't have root certificate already, therefore, we are going to generate the root key at Line 4, and then in line number 7 we are generating the root certificate with a few details like in what geographic region you are creating this cert and setting CN as local certificate, validity of our root certificate in days etc. if you notice, all certs are going to certs directory. Now at line 10 and 16 we are taking decision if operating system type is Linux or Mac OS. Depending on Operating System, we are executing steps to add the root certificate trusted root into our machine. Now, at line 27 and 28 we are generating private key and Certificate for our Nexus repository. Again, for your notice certificates are going to certs directory. and we are giving specific information such as DNS localhost, Validity of certificate, Subject Alt Name etc. Alright, so we have added root certificate as a trusted certificate in our machine and also we have generated the Nexus private key as well as Nexus certificate. After this, we are changing our current directory to nginx to copy the certs into docker context where we will create an image from Nginx. And at last we are executing docker compose to bring our Nginx and Nexus3 containers up and in running state. Now moving to Nginx directory, we see Dockerfile and Nginx configuration file. Looking at Dockerfile, here we are building our image from Nginx Alpine and then making a directory inside this image and then on top of that we are copying Nexus private key and certificate and finally copying our configuration file for Nginx server.
Looking at configuration file, inside http tag we set the SSL as ON so Nginx can accept https requests, then we have set SSLcertificate and SSLCertificateKey value as absolute path within the container. If you remember, we have provided this same path in Dockerfile for the certificate and private key. Now we quickly scroll down, here nginx server is listening at 443 port and then we are setting proxypass as HTTP Nexus-repo to port 8081 (port 8081 is default port used by Nexus). So basically, nginx is set to listen at 443 and any http request at 443 is set to redirect ect to Nexus-repo:8081. Nexus-repo is going to be our container name for Nexus3 repository and similarly when server will listen on port numbers 6666 it will redirect request to Nexus container port number 5555 and requests on 7777 will be redirected to 4444. It is important that we keep HTTP_host as proxy set header whenever you create the docker registry.

Опубликовано:

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 24   
@jasonkim2295
@jasonkim2295 3 года назад
Thank you very much!!! Just What I want ....
@shashanksharmadevops
@shashanksharmadevops 3 года назад
I am glad this helped.
@clovisguillaume5424
@clovisguillaume5424 8 месяцев назад
Hello, thanks for this video and happy new year ! You talk about "anonymous access" at a moment but not showing how/where it must be configure on nexus administration panel. Can you detail more this part please ? regards.
@Mariusz-lb3pj
@Mariusz-lb3pj 2 месяца назад
I see some problems with this solutions. Example I just remove cert from system and update certs and I can still have access to registry and proxy ;/
@Fayaz-Rehman
@Fayaz-Rehman 2 года назад
Thanks - would like to see the same in kubernetes with Lets Encrypt ssl certoficates.
@moussadiasoumahoro7621
@moussadiasoumahoro7621 3 года назад
Good
@shashanksharmadevops
@shashanksharmadevops 3 года назад
Thanks!
@suikast420
@suikast420 2 года назад
Why do you need ngnix if yo want only single nexus server ?
@shashanksharmadevops
@shashanksharmadevops 2 года назад
I think I have explained it somewhere in the video but here is the quick one. 1. The first part of the document explains the goodness of this implementation. help.sonatype.com/repomanager3/installation/run-behind-a-reverse-proxy 2. The maintenance such as cert renewal and nexus upgrade become very easy with this implementation. 3. Implementing cert at Nexus container is complex and error-prone than implementing it through reverse proxy. I hope this will help.
@suikast420
@suikast420 2 года назад
@@shashanksharmadevops I am even disagree with the arguments of nexus. Sure that's more convenient to setup an ingress that does SSL termination and everything is fine with the installation behind. It's easy to setup and maintain. That's right. But the backend communicates in it's internal cluster unprotected right ? What if your backend is hijacked ? Or you have a trojan ? IMHO you need a secured Ingress if you want do load balancing ( auditing is more comfortable but if auditing is a concern then I prefer more suitable solutions like service meshes) . We can't talking about security and convenience together. Convenience is the enemy of security. You shouldn't be lazy if you want have a secure system. If things like cert rotation is a concern then look at stuff like cert bot and vault for example. On point 3 you are talking about that implementing cert in nexus is hard right ? Its really not. 1. Create your certificate chain. 2. Make a bundle of your chain 3. Import it over keytool in nexus 4. Change the jetty config. 5. Change the nexus.properties That's it.
@antonyjohnsoni5483
@antonyjohnsoni5483 3 года назад
Thanks for your video.. I have a query how can i enable ssl for specific repos?
@shashanksharmadevops
@shashanksharmadevops 3 года назад
Interesting, are you saying we want few repos without ssl?
@geosystems2106
@geosystems2106 Год назад
Let me challenge the "why" of this .. Do we install the nginx as a reverse proxy to run nexus 3 in http mode rather than https ??
@shashanksharmadevops
@shashanksharmadevops Год назад
No, there are several benefits of implementing reverse proxy. However, this video is focused on https implementation.
@geosystems2106
@geosystems2106 Год назад
Just a mental note for myself: Reverse Proxy is widely for 1) Isolating and abstracting internal traffic 2) Separation of external and internal comms. security requirements 3) Load Balancing 4) Caching 5) Different QoS for different users (Canary deployment)
@nagasatishvadlamuri8486
@nagasatishvadlamuri8486 3 года назад
hi sharma...good explanation...i did step by step...i got output well...but i tried to depoy in kubernetes this private docker image which is stored in nexus repo...not deloying image....image pulloff and Errorimage i getting...can u please say how to deploy in kubernetes
@shashanksharmadevops
@shashanksharmadevops 3 года назад
Hi, I didn’t try it with k8. Could you paste error?
@kalpeshkolap3525
@kalpeshkolap3525 2 года назад
Facing same issues
@kalpeshkolap3525
@kalpeshkolap3525 2 года назад
Help us sir
@sauravshakya3062
@sauravshakya3062 2 года назад
Were you able to find out how to do it in K8?
@kalpeshkolap3525
@kalpeshkolap3525 2 года назад
Imagepullbackoff occurs in deployment and sir please make a video on ssl nexus docker registry
@sergio9725
@sergio9725 3 года назад
Hello, nice video! One question: can i sign and upload signed images with this?
@shashanksharmadevops
@shashanksharmadevops 3 года назад
I think so. Did you try and got an error?
@argord
@argord 2 года назад
Hello kind sir! I followed the tutorial up to the point to login into the local docker registry. It says Error response from daemon: Get "localhost:6666/v2/": unauthorized: authentication required, even after Docker Bearer token Realm configuration. Why could these possibly be? Another question, how can we generate a certificate that can match if you access the Nexus 3 repo from outside docker network ? I hope this was clear enaough! Thx for the video BTW!! Have a great new year!
Далее
Quick and Easy Local SSL Certificates for Your Homelab!
12:08
Fake watermelon by Secret Vlog
00:16
Просмотров 10 млн
Proxy vs Reverse Proxy (Real-world Examples)
5:17
Просмотров 554 тыс.
The NGINX Crash Course
50:53
Просмотров 486 тыс.
Docker and Nginx Reverse Proxy
31:32
Просмотров 115 тыс.
Master Traefik 3 in 60 min: Best Docker Reverse Proxy
56:39
Docker Private Registries | Nexus and Registry:2
46:55
Просмотров 3,1 тыс.