Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hi there!
I am trying to get two domains running on one droplet (nginx) with the same SSL certificate, and as a newbie to this, I have been tearing out my hair for a day trying to get it to work.
My configuration for the first domain is this the following. Its a node app, and it’s working fine:
#domain1
server {
listen 80 default_server;
root /home/Bas/domain1;
index index.html index.htm;
server_name www.domain1.com domain1.com;
return 301 https://$server_name$request_uri;
}
server {
server_name www.domain1.com domain1.com;
listen 443 ssl http2;
ssl_certificate /etc/letsencrypt/live/www.domain1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.domain1.com/privkey.pem;
include /etc/nginx/snippets/ssl-params.conf;
location / {
proxy_pass http://localhost:3001;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
location ~ /.well-known {
allow all;
}
}
The second domain is for a static website, and it was working before I tried to install the https. I think I got something wrong in the configuration file which you can see below:
#domain2
server {
listen 80;
server_name domain2.com www.domain2.com
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name domain2.com www.domain2.com;
root /home/Bas/domain2;
index index.html index.htm;
ssl_certificate /etc/letsencrypt/live/domain2.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain2.com/privkey.pem;
include /etc/nginx/snippets/ssl-params.conf;
location / {
try_files $uri $uri/ =404;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:80/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
location ~ /.well-known {
allow all;
}
}
I’ve been trying a lot of different solutions and I have been running into multiple different errors, depending on my configuration: 502 bad gateway, “Welcome to Nginx, further configuration is required”, “too many redirects”, and at the moment I get the first Node app on both domains. Really stuck here, so any help would be much appreciated!
Edward Sitarski
1fd6b9d2a2b94ee4b3e8ee6d5e2587
Traceurity
fadecomic
Mollie Semmes
Will Walters
f4df2e98b9c74f7eb7f6a0629cf1c4
erel
fingers
fingers