Problem installing wordpress on subdomain (nginx / ubuntu)

December 6, 2017 64 views
Nginx WordPress DNS LEMP Ubuntu 16.04


I've been trying to configure my single droplet to host two different website on two different domain, where one of them is a subdomain:

  1. My homepages (static - home/about/contact etc)
  2. Blog (Dynamic - Wordpress)

I'm using Nginx and have the following config files

Main -

server {
        listen 443 default_server;
        listen [::]:443 default_server;

        root /var/www/;
        index index.html;

        ssl on;
        ssl_certificate /etc/letsencrypt/live/;
        ssl_certificate_key /etc/letsencrypt/live/;

        location / {     try_files $uri $uri/ =404;

server {
       rewrite ^ https://$host$request_uri? permanent;

Subdomain -

server {
listen 80;
listen [::]:80;
return 301$request_uri;

root /var/www/;

index index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;

location ~ /\.ht {
deny all;

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;

The main site is working, but when I try to access the sub domain I get greeted by an error message saying that "'s server DNS address could not be found".

I can Ping and nslookup the server using the subdomain address ( and it returns the IP-address of my server.

I suspect that I've done something wrong with my DNS records but I can't figure out what that might be. I've set up CNAME records, A records, and Wildcard records(* for my subdomain.

Has anybody had this problem and if so, how were you able to resolve it?


Be the first one to answer this question.