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
}
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.
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
Click below to sign up and get $100 of credit to try our products over 60 days!
There are a few things that I’d like to mention:
listen [::]:443 ssl ipv6only=on; # managed by Certbot
Comparing with your config for looxapp.gr which specifies both IPv4 and IPv6:
listen [::]:443 ssl; # managed by Certbot listen 443 ssl; # managed by Certbot
There are no AAAA records for gleep.app for IPv6.
Is IPv6 enabled for your Droplet(s)?
You may also want to consider setting listen directives in the main server config and not in the server blocks but that is up to you! Here are a few relevant guides for easy reference:
https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
http://nginx.org/en/docs/http/request_processing.html