server {\r\n\r\n listen 443 ssl;\r\n server_name myDokuWiki.org;\r\n root \/home\/your_user\/myDokuWiki.org;\r\n\r\n access_log \/var\/log\/nginx\/dokuwiki.access.log;\r\n error_log \/var\/log\/nginx\/dokuwiki.error.log;\r\n\r\n ssl on;\r\n ssl_certificate \/etc\/nginx\/ssl\/dokuwiki.crt;\r\n ssl_certificate_key \/etc\/nginx\/ssl\/dokuwiki.key;\r\n ssl_session_timeout 5m;\r\n ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';\r\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\r\n ssl_prefer_server_ciphers on;\r\n\r\n index index.html index.php doku.php;\r\n\r\n location \/ {\r\n try_files $uri $uri\/ @dokuwiki;\r\n }\r\n\r\n location @dokuwiki {\r\n rewrite ^\/_media\/(.*) \/lib\/exe\/fetch.php?media=$1 last;\r\n rewrite ^\/_detail\/(.*) \/lib\/exe\/detail.php?media=$1 last;\r\n rewrite ^\/_export\/([^\/]+)\/(.*) \/doku.php?do=export_$1&id=$2 last;\r\n rewrite ^\/(.*) \/doku.php?id=$1 last;\r\n }\r\n\r\n location ~ \/(data|conf|bin|inc)\/ {\r\n deny all;\r\n }\r\n\r\n location ~* \\.(css|js|gif|jpe?g|png)$ {\r\n expires 1M;\r\n add_header Pragma public;\r\n add_header Cache-Control \"public, must-revalidate, proxy-revalidate\";\r\n }\r\n\r\n location ~ \\.php$ {\r\n fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n fastcgi_pass unix:\/var\/run\/php-fpm-your_user.sock;\r\n fastcgi_index index.php;\r\n include fastcgi_params;\r\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n fastcgi_intercept_errors off;\r\n fastcgi_buffer_size 16k;\r\n fastcgi_buffers 4 16k;\r\n }\r\n\r\n location ~ \/\\.ht {\r\n deny all;\r\n }\r\n}\r\n\r\nserver {\r\n listen 443 ssl;\r\n server_name www.myDokuWiki.org;\r\n\r\n ssl on;\r\n ssl_certificate \/etc\/nginx\/ssl\/dokuwiki.crt;\r\n ssl_certificate_key \/etc\/nginx\/ssl\/dokuwiki.key;\r\n ssl_session_timeout 5m;\r\n ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';\r\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\r\n ssl_prefer_server_ciphers on;\r\n\r\n add_header Strict-Transport-Security max-age=2592000;\r\n rewrite ^ https:\/\/myDokuWiki.org$request_uri? permanent;\r\n}\r\n\r\nserver {\r\n listen 80;\r\n server_name myDokuWiki.org www.myDokuWiki.org;\r\n\r\n add_header Strict-Transport-Security max-age=2592000;\r\n rewrite ^ https:\/\/myDokuWiki.org$request_uri? permanent;\r\n}\r\n<\/pre>\nThe configuration above will redirect all HTTP traffic to HTTPS and www URLs to non-www.<\/p>\n
Do not forget to change your_user with your username.<\/p>\n
Activate the server block by creating a symbolic link :<\/p>\n
[user]$ sudo ln -s \/etc\/nginx\/sites-available\/myDokuWiki.org \/etc\/nginx\/sites-enabled\/myDokuWiki.org<\/pre>\nTest the Nginx configuration and restart nginx:<\/p>\n
[user]$ sudo nginx -t\r\n[user]$ sudo service nginx restart<\/pre>\n