===== Simple configuración de Nginx para DokuWiki bajo HTTPS=====
**Versión Nginx**: 1.2.1\\
**Versión Dokuwiki**: 2014-05-05a "Ponder Stibbons"
**Lectura recomendada**: [[https://www.dominio.com/dokuwiki_corriendo_en_nginx|Simple configuración de Nginx para DokuWiki]]
==== Ejemplo de fichero de configuración ====
server {
server_name dominio.com www.dominio.com 191.89.94.37;
if ( $host = 'dominio.com' ) {
rewrite ^/(.*)$ https://www.dominio.com/$1;
}
########### SSL ###########
listen 443; ## listen for ipv4; this line is default and implied
ssl on;
ssl_certificate /etc/nginx/ssl_cert/dominio_ssl.chained.crt;
ssl_certificate_key /etc/nginx/ssl_cert/dominio_ssl.key;
########### Forward Secrecy ###########
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
########### Session resumption (caching) ###########
ssl_session_cache shared:ssl_session_cache:10m;
###########
autoindex off;
client_max_body_size 15M;
client_body_buffer_size 128k;
index index.html index.htm index.php doku.php;
access_log /var/log/nginx/dominio.com/access.log;
error_log /var/log/nginx/dominio.com/error.log;
root /usr/share/nginx/www/dominio;
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;
}
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; }
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;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
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;
fastcgi_param HTTPS $php_https;#DW checks $_SERVER['HTTPS']
fastcgi_param HTTPS on;
}
location ~ /(data|conf|bin|inc)/ {
deny all;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
**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;
}