Stuck trying to access different ports using docker containers from https

I have two containers with different apps (n8n and mautic) that are accesible via http using different ports (8080 and 5678) but cant be while using https

I noticed that https:mywebsite.com is accesible but not https:mywebsite.com:5678 and https:mywebsite.com:8080

what should i do to manage SSL? im using ubuntu 20.04

Hi @Myok, welcome to the community :tada:

I noticed that https:mywebsite.com is accesible but not https:mywebsite.com:5678 and https:mywebsite.com:8080

This sounds you might be running a reverse proxy. This would sit between the internet and your applications and receives all the web traffic coming in on port 80/443 (the default ports used when navigating to http://website.com or https://website.com without specifying a port). It typically handles SSL/TLS termination (meaning it’s the place where such certificates are managed) and then proxies the traffic to your applications listening on various other ports on your server.

In general, a reverse proxy is a great idea, but it adds a bit of complexity. Can you confirm how exactly you have set up n8n and what exactly you want to manage with regards to SSL?

1 Like

Thanks @MutedJam for your answer

I have the docker installation from here Docker - n8n Documentation

Together with the docker install for mautic from here Docker Hub and nothing else

How can I handle the SSL to both ports be accesible via https?

So you are simply running n8n by typing

docker run -it --rm \
    --name n8n \
    -p 5678:5678 \
    -v ~/.n8n:/home/node/.n8n \
    n8nio/n8n

This would mean n8n is exposed on port 5678 of your machine without handling SSL or TLS. Meaning you’d need to use http://website.com:5678 to access it (but it’s not a good idea to do so, because it wouldn’t use any SSL/TLS encryption).

Seeing you mentioned that https:mywebsite.com is accessible instead, what do you see when opening that particular website?

And what would sudo ss -tulpn | grep :80 and sudo ss -tulpn | grep :443 return for you on your server (this command should confirm which application is listening on your HTTP & HTTPS ports)?

apache2, docker-proxy

What should be the correct approach to handle SSL and TLS in this case?

So I personally prefer bare metal nginx to receive all incoming HTTP/HTTPS traffic, manage my SSL certificates and then pass traffic on to my docker containers or other services so I don’t have to expose any other ports apart from 80 & 443 directly.

I’ve wrote a quick guide on how to set up an Oracle Cloud VM like that here if you’re considering such an approach (most of it is not specific to Oracle Cloud and will apply to other cloud VPS as well):

Our documentation has an example Docker Compose/Traefik setup:

https://docs.n8n.io/hosting/server-setups/docker-compose/

I hope this helps getting started. There are several other valid approaches too. I know @jon for example likes Nginx Proxy Manager, a UI for Nginx that saves you from having to configure Nginx manually. Note that all of these approaches would require you to disable any other applications listening on ports 80 and 443 first.

There is also some users of Apache as a reverse proxy with n8n out there, but I am not sure how to configure that one properly unfortunately. You might get more help in a community focused on Apache if this is a hard requirement for you.

Okay, thanks for your answer, im pretty new at this. I made some progress

I installed Nginx Proxy Manager, changed the port for Apache so it doesnt conflicts with nginx and now one of the apps works fine with https, but n8n sends me to gateway 504

When i enter directly using the port by urlname.com:5678 it works fine, but wont recognize the https

EDIT: Is working now, it was an issue with the SSL, thanks a lot for your help