Nginx Server Block Resulting in Server Not Found

Hey there.

Brand new trellis install.

wordpress_sites:
  www.client.com:
    site_hosts:
      - clientnew.dev
    local_path: '../site' # path targeting local Bedrock project directory (relative to Ansible root)
    repo: git@bitbucket.org:clientweb/client.git
    site_install: true
    site_title: Client Side
    admin_user: Brandon Shutter
    admin_password: pass
    admin_email: brandon@brandonshutter.com
    multisite:
      enabled: false
      subdomains: false
    ssl:
      enabled: true
      cert: '../site/ssl/bundle.crt'
      key: '../site/ssl/client_com.key'
    system_cron: true
    env:
      wp_home: https://clientnew.dev
      wp_siteurl: https://clientnew.dev/wp
      wp_env: development
      db_name: clientnew.dev
      db_user: caltondb_user
      db_password: rbandona_dbpassword

After a successful provision, my sites-available looks like this:

server {
    listen 443 ssl spdy;

  server_name  clientnew.dev;
  access_log   /srv/www/www.client.com/logs/access.log;
  error_log    /srv/www/www.client.com/logs/error.log;

  root  /srv/www/www.client.com/current/web;
  index index.php;

  charset utf-8;

  # See Virtualbox section at http://wiki.nginx.org/Pitfalls
  sendfile off;

    include ssl.conf;
  include ssl-stapling.conf;

  add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
  add_header X-Frame-Options SAMEORIGIN;

    ssl_certificate         /etc/nginx/ssl/bundle.crt;
  ssl_trusted_certificate /etc/nginx/ssl/bundle.crt;
  ssl_certificate_key     /etc/nginx/ssl/client_com.key;


  include includes.d/www.client.com/*.conf;
  include wordpress.conf;

  location ~ \.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    fastcgi_pass unix:/var/run/php5-fpm-wordpress.sock;
    client_max_body_size 0;
  }
}

server {
  listen 80;
  server_name clientnew.dev;
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl spdy;
  server_name www.clientnew.dev;
    return 301 $scheme://clientnew.dev$request_uri;
}

When going to clientnew.dev it redirects to 443 correctly, but results in ERR_CONNECTION_REFUSED.

Pinging clientnew.dev results in the correct ip address assigned in the vagrantfile.

You could always try a vagrant reload just to be sure that Nginx correctly restarted. (Or just vagrant ssh then sudo service nginx reload)

When sshing in via vagrant ssh and running sudo service nginx reload I get the following error:

vagrant@caltonnew:~$ sudo service nginx reload
reload: Unknown instance:
vagrant@caltonnew:~$ sudo service nginx start
nginx stop/pre-start, process 6275
vagrant@caltonnew:~$ sudo service nginx reload
reload: Unknown instance:

Try sudo nginx -t on the VM to validate the config. If I had to guess, i think its related to your SSL certificate.

1 Like