server { listen 80; server_name myexample.com; return 301 https://myexample.com$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name myexample.com; root /var/www/wiki/; index pmwiki.php; location ~ ^/(cookbook|local|scripts|wiki.d|wikilib.d) { deny all; } location / { try_files $uri $uri/ @pmwiki; } location @pmwiki { rewrite ^/(.*) /pmwiki.php?n=$1; } ## php configuration using unix sockets. location ~ \.php$ { fastcgi_pass 127.0.0.1:9999; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } # cache configuration for most common files location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { # Some basic cache-control for static files to be sent to the browser expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } # drop common log errors 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; } # If iRedMail is operating on server, remove # on two below # ssl_certificate /etc/ssl/certs/iRedMail.crt; # ssl_certificate_key /etc/ssl/private/iRedMail.key; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log info; }