I have 3 domains setup, 1 is irrelevant, and 1 is new. The problem is that it redirects, I think, to my other domain. I say I think because Firefox/Chrome give an error due to mismatch to name provided in the certificate: it uses the name of my other domain. Safari on the other hand displays the default Nginx page.

Check this:

https://check-your-website.server-daten.de/?q=gleep.app

It shows that the certificate and even screenshots come from my other domain, looxapp.gr

I have read a million other topics like this but I still can’t solve it.

gleep.app:

server {

        root /gleep/admin/build;
        index index.html index.htm index.nginx-debian.html;

        server_name www.gleep.app gleep.app;

        location / {
        try_files $uri $uri/ /index.html;
#               try_files $uri $uri/ =404;
#         proxy_pass http://localhost:8085;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection 'upgrade';
         proxy_set_header Host $host;
         proxy_cache_bypass $http_upgrade;
       }
    listen [::]:80;


    listen [::]:443 ssl ipv6only=on;  # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/gleep.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/gleep.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}


looxapp.gr: (bar and admin subdomains don’t work but that’s ok)

server {

        root /looxbrowser/build;
        index index.html index.htm index.nginx-debian.html;

        server_name looxapp.gr www.looxapp.gr;

        location / {
    try_files $uri $uri/ /index.html;
                #try_files $uri $uri/ =404;
#         proxy_pass http://localhost:8083;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection 'upgrade';
         proxy_set_header Host $host;
         proxy_cache_bypass $http_upgrade;
        }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/looxapp.gr/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/looxapp.gr/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

server {

    root /looxbar/build;
    index index.html index.html index.nginx-debian.html;

    server_name bar.looxapp.gr;

    location / {
        try_files $uri $uri/ =404;
        proxy_pass http://localhost:8083;
        proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;

    }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/looxapp.gr/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/looxapp.gr/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    root /admin/build/;
    index index.html index.html index.nginx-debian.html;

    server_name admin.looxapp.gr;
    location / {
        try_files $uri $uri/ /index.html;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/looxapp.gr/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/looxapp.gr/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = www.looxapp.gr) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = looxapp.gr) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;  
        listen [::]:80;

        server_name looxapp.gr www.looxapp.gr;
    return 404; # managed by Certbot




}

server {
    if ($host = bar.looxapp.gr) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    listen [::]:80;

    server_name bar.looxapp.gr;
    return 404; # managed by Certbot


}

server {
    if ($host = admin.looxapp.gr) {
        return 301 https://$host$request_uri;
    } # managed by Certbot



    server_name admin.looxapp.gr;
    listen 80;
    return 404; # managed by Certbot


}

1 comment

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.

×
1 answer

Hi there @tkmkds,

I think that this is because you have proxy rules but you have not specified the proxy_pass for your domains. Do you need the reverse proxy rules or do you want your websites to be only loading the content of the document root that you’ve specified?

What I could suggest is using the Nginx tool to generate your Nginx configuration:

https://www.digitalocean.com/community/tools/nginx

It allows you to add multiple sites, SSL server blocks and also create reverse proxy setup.

Regards,
Bobby

  • Thanks so much for your reply. Don’t wanna seem rude but isn’t there something quicker I could use? This seems a lot of work and information that I don’t understand - I don’t wanna ruin anything..

    • If you take snapshots of your Droplet before making any changes, you can always revert back to that snapshot if things don’t go as planned. You can consider making a “Golden Image” of your setup that you can use as a save point: https://www.digitalocean.com/docs/images/snapshots/how-to/snapshot-droplets/

      Having saved snapshots as well as local backups allows you to experiment while minimizing risk. Don’t change too many things at once, it’s essential to understand how things are changing based on your modifications. Over time though, the more you try things out the stronger your skills will grow.

      That tool that Bobby linked is pretty powerful, so definitely check it out!

  • -Do you need the reverse proxy rules or do you want your websites to be only loading the content of the document root that you’ve specified?

    I am not sure what you mean. Both are front websites that talk to their respective Node backends that run on the droplet.

    • Hi there @tkmkds,

      In this case, I believe that you need to make sure that you have the proxy_pass rule specified for each server block.

      Let me know how it goes!
      Regards,
      Bobby

      • If I specify proxy_pass, then I am no longer available to access www.looxapp.gr and I still get the same error on gleep.app

Submit an Answer