server { listen 80; server_name example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl http2; server_name example.com; root /home/user1/Dokuwiki/xxx; index doku.php; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; location / { try_files $uri $uri/ @dokuwiki; } location @dokuwiki { rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; rewrite ^/(?!lib/)(.*) /doku.php?id=$1&$args last; } # http://example.com/wiki:welcome のようなURLを # http://example.com/wiki/welcome のようなURLにリダイレクト location ~ ^/.+:.+$ { rewrite ^([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):(.+)$ $1/$2/$3/$4/$5/$6/$7/$8/$9; rewrite ^([^:]+):([^:]+):([^:]+):([^:]+):(.+)$ $1/$2/$3/$4/$5; rewrite ^([^:]+):([^:]+):(.+)$ $1/$2/$3; rewrite ^([^:]+):(.+)$ $1/$2; rewrite .* $uri permanent; } location ~ \.php$ { if (!-f $request_filename) { return 404; } # http://example.com/doku.php?id=wiki:welcome のようなURLを # http://example.com/wiki/welcome のようなURLにリダイレクト if ($request_uri ~ ^/doku.php\?id=(?.+)$) { rewrite .* /$query?; rewrite ^([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):(.+)$ $1/$2/$3/$4/$5/$6/$7/$8/$9; rewrite ^([^:]+):([^:]+):([^:]+):([^:]+):(.+)$ $1/$2/$3/$4/$5; rewrite ^([^:]+):([^:]+):(.+)$ $1/$2/$3; rewrite ^([^:]+):(.+)$ $1/$2; rewrite .* $uri permanent; } include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS on; fastcgi_pass 127.0.0.1:9000; #fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; } location ^~ /bin/ { return 403; } location ^~ /conf/ { return 403; } location ^~ /data/ { return 403; } location ^~ /inc/ { return 403; } location ~* /\.well-known { allow all; } location = /sitemap.xml.gz { root /home/user1/Dokuwiki/xxx/data/cache; } }