DISREGARD - I just needed to set up my SSL :-/
I would like to set up a sub-domain “cms.example.com”, on a second server, for my CMS. The IP address for the sub-domain’s server works, but the URL just times out. I believe its a problem with my nginx server blocks but I’m not positive.
I set up an A record on the DNS for example.com to point to the subdomain on the 2nd server. I do currently have a working subdomain for my Hike SEO portal that points to their app, “hike.example.com” with an A record recorded on the DNS for example.com
Here’s the nginx Server block for example.com, with replacement text for the IPs and domains:
server {
listen SERVER1_IP:443 ssl http2;
listen [::]:443 ssl http2 ipv6only=on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.4.4 8.8.8.8;
root /var/www/example.com/html;
index index.html index.html index.nginx-debian.html;
server_name example.com;
location / {
proxy_pass 'http://localhost:3000';
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;
}
expires $expires;
}
server {
if ($host = example.com) {
return 301 https://$host$request_uri;
}
listen SERVER1_IP:80;
listen [::]:80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
listen SERVER1_IP:80;
listen SERVER1_IP:443;
server_name www.example.com;
location / {
return 301 https://example.com$request_uri;
}
}
And here’s the server block for cms.example.com–(Note, I have not yet set up SSL on the subdomain)
server {
listen SERVER2_IP:80;
root /var/www/cms;
index index.html index.htm;
server_name cms.example.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
location ~/\.ht {
deny all;
}
}
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!
Hey @danielbranda,
Basically, if you were accessing the subdomain at https://subdomain.example.com then yes you needed a nginx config file for port 443 with an SSL.
Having said that you should’ve been posible to open the website with http - http://subdomain.example.com
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.