Versión Nginx: 1.2.1
Versión Dokuwiki: 2014-05-05a “Ponder Stibbons”
server { server_name dominio.com www.dominio.com; ############### URL Canónica if ( $host != 'www.dominio.com' ) { rewrite ^/(.*)$ http://www.dominio.com/$1 permanent; } listen 80; autoindex off; client_max_body_size 15M; client_body_buffer_size 128k; index index.html index.htm index.php doku.php; ############### Logs access_log /var/log/nginx/dominio.com/access.log; error_log /var/log/nginx/dominio.com/error.log; root /usr/share/nginx/www/dominio; ############### Page Errors error_page 500 502 503 504 404 403 /404.html; include /etc/nginx/block.conf; location = /404.html { root /usr/share/nginx/www/dominio/error; allow all; } location / { try_files $uri $uri/ @dokuwiki; } ############### Contenido estático (Proxy cache) location ~ ^/lib.*\.(gif|png|ico|jpg|css|js)$ { expires 31536000s; add_header Pragma "public"; add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate"; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } location ~ /\. { access_log off; log_not_found off; deny all; } location ~ ~$ { access_log off; log_not_found off; deny all; } ############### URL amigables. 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 ^/(.*) /doku.php?id=$1 last; } ############### Soporte para php CGI location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_param PATH_INFO $uri; } ############### Denegación de acceso. location ~ /(data|conf|bin|inc)/ { deny all; } location ~ /\.ht { deny all; } }
service nginx restart
Problema al visualizar imágenes en Dokuwiki con Nginx
En la web de dokuwiki se propone una configuración de Dokuwiki en Nginx con unas directivas que impiden la visualización de imágenes en los artículos. Para solventarlo vale con comentar / eliminar las siguientes lineas. El código puede variar pero se debe identificar fácilmente si nos basamos en el ejemplo.
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { access_log off; log_not_found off; expires 360d; }