Question

How to correctly setup sub-domains with ssl and nginx as a proxy?

I managed to configure nginx reverse proxys and ssl in order to run a Directus 9 Docker installation.

But my actual goal is to run 3 separate Directus 9 Docker installations on 3 subdomains (like “jvds.my-domain.org”). The sub-domains open the proper index sites (from their defined subfolders) as long as there is no proxy_pass defined (in the nginx block configuration):

#/etc/nginx/sites-enabled/jvds.scores-catalog.org.conf

server {
    root /var/www/jvds.scores-catalog.org/html;
    index index.html index.htm index.nginx-debian.html;
    server_name jvds.scores-catalog.org;
    location / {
        try_files $uri $uri/ =404;
        #proxy_pass http://127.0.0.1:8055;

As soon as proxy_pass is active, the subdomain does not open properly; and the running terminal on the main domain (the one with the working Directus installation) detects something and prints to the console.

Also, when running docker-compose, this command seems to influence all instances! A docker-compose down stops all docker instances. How can I execute docker containers in each subdomain separately?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
March 22, 2023

Hi there,

Is your Nginx service also running inside a Docker container? If this is the case, you would need to update this line here:

# proxy_pass http://127.0.0.1:8055;

And change the 127.0.0.1 IP with the container name of the backend service that you are using.

Feel free to share more details about your setup, like your Docker compose file so I could advise you further.

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up