Redirect nginx to ssl docker sevice

Published

I have a server on Hetzner do I configured several services on doker. In this case Portainer and Node-red.
I have connected a ddns domain pointing to the server ip and configured via certbot standalone the certificates individually for each service.
I can access both correctly via the following links:
https://myfreedomain.ddns.net:9000 (portainer)
https://myfreedomain.ddns.net:1880 (node-red)

I would like to configure nginex in such a way that I can access the services via path and force an ssl redirect.
Example:
http://myfreedomain.ddns.net/portainer –> https://myfreedomain.ddns.net:9000
The certificates are loaded and configured in the individual services

NgineX site-enable configfile:

server {
listen 443 ssl;
server_name myfreedomanin.ddns.net;
ssl_certificate     /etc/letsencrypt/live/myfreedomanin.ddns.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myfreedomanin.ddns.net/privkey.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

location /portainer     {
    proxy_pass https://myfreedomanin.ddns.net:9000;
}
location /node-red {
    proxy_pass https://myfreedomanin.ddns.net:1880;
}
}

the default configuration file is also present

Source: Docker Questions

Published
Categorised as docker, nginx, ssl, ubuntu Tagged , , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq