map $scheme $php_https { default off; https on; }

    server {
      server_name wiki.host.org
      root /path/to/dokuwiki;
      index doku.php;
      listen 80;
      #Enforce https for logins, admin
      if ($args ~* do=(log|admin|profile)) {
        rewrite ^ https://$host$request_uri? redirect;
      }
      include dokuwiki.conf;
    }

    server {
      server_name wiki.host.org;
      root /path/to/dokuwiki;
      index doku.php;
      listen 443 ssl;
      keepalive_requests    10;
      keepalive_timeout     60 60;
      ssl_certificate      /etc/ssl/certs/ssl-cert-snakeoil.pem;
      ssl_certificate_key  /etc/ssl/private/ssl-cert-snakeoil.key;
      #switch back to plain http for normal view

      if ($args ~* (do=show|^$)){
        rewrite ^ http://$host$request_uri? redirect;
      }
      include dokuwiki.conf;
    }
