Nginxconf: Difference between revisions

From GaryH Tech's Wiki
No edit summary
Blanked the page
Tag: Blanking
Line 1: Line 1:
Redirect for wiki.garyhtech.uk<br>


        server {<br>
        listen         80;<br>
        server_name    wiki.garyhtech.uk;<br>
        return         301 <nowiki>https://$server_name$request_uri</nowiki>;<br>
        }<br>
server {<br>
       listen 443 ssl;<br>
       #listen [::]:80;<br>
       http2 on;<br>
       server_name wiki.garyhtech.uk;<br>
       ssl_certificate      /usr/local/etc/letsencrypt/live/garyhtech.uk/fullchain.pem;<br>
       ssl_certificate_key  /usr/local/etc/letsencrypt/live/garyhtech.uk/privkey.pem;<br>
       access_log      /usr/local/etc/nginx/logs/wiki.garyhtech.uk.log;<br>
       error_log       /usr/local/etc/nginx/logs/wiki.garyhtech.uk-error.log;<br>
      root /usr/local/www/mediawiki;<br>
      index index.php;<br>
      add_header X-Content-Type-Options "nosniff";<br>
      # allow larger file uploads and longer script runtimes<br>
      client_max_body_size 100m;<br>
      client_body_timeout 60;<br>
      # Images
      location /w/images {
      # Separate location for images/ so .php execution won't apply
      add_header X-Content-Type-Options "nosniff";
    }
      location /w/images/deleted {
      # Deny access to deleted images folder
      deny all;
    }
      # MediaWiki assets (usually images)
      location ~ ^/w/resources/(assets|lib|src) {
      try_files $uri 404;
      add_header Cache-Control "public";
      expires 7d;
    }
      # Assets, scripts and styles from skins and extensions
       location ~ ^/w/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|wasm)$ {
      try_files $uri 404;
      add_header Cache-Control "public";
      expires 7d;
    }
      # License and credits files
      location ~ ^/w/(COPYING|CREDITS) {
      default_type text/plain;
    }
      location ~ \.php$ {
      try_files $uri =404;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php81-fpm.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
      }
      location / {
      try_files $uri $uri/ /index.php?$args;
      }
}

Revision as of 13:37, 15 December 2025