Error: nginx: [emerg] unexpected "/" in /etc/nginx/sites-enabled/mydomain.conf:48

Have Trellis version with Enable per-site setup for permalink structure ([#661]

I am getting an NGINX error when I run vagrant up that I think is connected to some cache control configs. Is it possible that they need to be written differently now?

If I have the following applied in development/wordpress_sites.yml (see below)

    cache:
      enabled: true
      duration: 30s
      skip_cache_uri: /wp-admin/|/xmlrpc.php|wp-..php|/feed/|index.php|sitemap(_index)?.xml|* "/gear.|/cart.|/my-account.|/checkout.|/addons.
      skip_cache_cookie: comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_cart_hash|woocommerce_items_in_cart|wp_woocommerce_session_|woocommerce_recently_viewed

I get the following error

RUNNING HANDLER [common : command] *********************************************
System info:
  Ansible 2.0.2.0; Vagrant 1.8.5; Darwin
  Trellis at "Enable per-site setup for permalink structure"
---------------------------------------------------
nginx: [emerg] unexpected "/" in /etc/nginx/sites-enabled/diveidc.com.conf:48
nginx: configuration file /etc/nginx/nginx.conf test failed
fatal: [default]: FAILED! => {"changed": true, "cmd": ["nginx", "-t"], "delta": "0:00:00.023851", "end": "2016-10-07 17:59:16.226771", "failed": true, "rc": 1, "start": "2016-10-07 17:59:16.202920", "stderr": "nginx: [emerg] unexpected \"/\" in /etc/nginx/sites-enabled/diveidc.com.conf:48\nnginx: configuration file /etc/nginx/nginx.conf test failed", "stdout": "", "stdout_lines": [], "warnings": []}

RUNNING HANDLER [common : service] *********************************************
System info:
  Ansible 2.0.2.0; Vagrant 1.8.5; Darwin
  Trellis at "Enable per-site setup for permalink structure"
---------------------------------------------------
Job for nginx.service failed because the control process exited with error
code. See "systemctl status nginx.service" and "journalctl -xe" for details.

fatal: [default]: FAILED! => {"changed": false, "failed": true}

If I remove it, things are all good.

I have followed the docs on how to apply skip_cache_uri and skip_cache_cookie but I think something has changed in the setup resulting in the error?

Updated to the following :

  • changed sitemap(_index)?.xml|* "/gear.| to sitemap(_index)?.xml|/gear.*
  • updated wp-..php to wp-.*.php

This has fixed things. Below is fully updated.

      enabled: true
      duration: 30s
      skip_cache_uri: /wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml|/gear.*|/cart.*|/my-account.*|/checkout.*|/addons.*
      skip_cache_cookie: comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_cart_hash|woocommerce_items_in_cart|wp_woocommerce_session_|woocommerce_recently_viewed

If you follow this discussion and copy/paste exactly what is written it may result in the same issue I had

I am still unsure if how I have written the cache control will still work as intended, will test shortly.

4 Likes

Nice one @buretta - will be using this from here on.