First, I struggled hard with the title. I've been trying back and forth, googling like mad and the resources I find are most likely way to complicated for me. But I find it so unbelievable that it's so hard to what I am trying to do which I believe should be super simple.
So; the setup.
I have a RaspberryPi "server" (henceforth 'server') with an NGINX installation. (Not a docker image) I have a cloudflare domain I bought, which have an A record (root) pointing to the IP of my server. It is also configured with their ssl/tls option with end-to-end encryption.
Everything works super fine. All configured. Browsing to my domain.tld points me to my site setup on my server, all good.
Now, the issue I have is that besides this NGINX installation, I am running docker services. Let's say..
1. music:1000
2. docker-admin:1001
Both are webGui's. I can access them fine by using myip:port over HTTP respectively. However. What I want is to access them either via domain.tld:port or better music.domain.tld, docker-admin.domain.tld that points to the docker service over HTTPS using the certs/tls I am using for my NGINX.
How on earth do I do this? (Please note that I've tried different attempts with the nginxproxymanager tool, but I am not interested in using that approach, I want it done through NGINX.)
Everything I've tried have failed with so many different errors I've lost track. Below is the current sites-available/domain.tld that is working.
Any ideas on how to approach this? Best regards! :) (note that domain.tld is not the real domain of course! )
server {
listen 80;
listen [::]:80;
server_name domain.tld www.domain.tld;
return 302 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
ssl_client_certificate /etc/ssl/cloudflare.crt;
ssl_verify_client on;
server_name domain.tld www.domain.tld;
root /var/www/domain.tld/html;
index index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
}