Problem installing wordpress on subdomain (nginx / ubuntu)


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?



Has this been fixed? I am looking for the same solution.

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Without knowing the domain I cannot say what the DNS related issue is but I am seeing a concern with the configuration you shared.

In your port 80 configuration for you are using a 301 redirect to send all traffic to HTTPS.

return 301$request_uri;

This means that your site configuration below this is not being used. A user requesting is immediately redirected to the matching path on but your port 443 configuration seems to only be configured for your main domain so any request to your server whether for blog or www are both redirected to your SSL site configuration which seems to only be set up to support your static site.