Nginxconf: Difference between revisions

From GaryH Tech's Wiki
Clean up formatting
Undo revision 18 by Gary (talk)
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
<code><nowiki>#</nowiki> Redirect for wiki.garyhtech.uk
#Redirect for wiki.garyhtech.uk
        server {
        listen        80;
        server_name    wiki.garyhtech.uk;
        return        301 https://$server_name$request_uri;
        }


        server {
server {    
        listen         80;
      listen 443 ssl;
        server_name    wiki.garyhtech.uk;
      #listen [::]:80;
        return         301 <nowiki>https://$server_name$request_uri</nowiki>;
      http2 on;
        }
      server_name wiki.garyhtech.uk;
      ssl_certificate      /usr/local/etc/letsencrypt/live/garyhtech.uk/fullchain.pem;
      ssl_certificate_key  /usr/local/etc/letsencrypt/live/garyhtech.uk/privkey.pem;
      access_log      /usr/local/etc/nginx/logs/wiki.garyhtech.uk.log;
      error_log      /usr/local/etc/nginx/logs/wiki.garyhtech.uk-error.log;


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

Latest revision as of 13:52, 15 December 2025

#Redirect for wiki.garyhtech.uk
       server {
       listen         80;
       server_name    wiki.garyhtech.uk;
       return         301 https://$server_name$request_uri;
       }
server {      
      listen 443 ssl;
      #listen [::]:80;
      http2 on;
      server_name wiki.garyhtech.uk;
      ssl_certificate      /usr/local/etc/letsencrypt/live/garyhtech.uk/fullchain.pem;
      ssl_certificate_key  /usr/local/etc/letsencrypt/live/garyhtech.uk/privkey.pem;
      access_log      /usr/local/etc/nginx/logs/wiki.garyhtech.uk.log;
      error_log       /usr/local/etc/nginx/logs/wiki.garyhtech.uk-error.log;
       root /usr/local/www/mediawiki;
       index index.php;
       add_header X-Content-Type-Options "nosniff";
       # allow larger file uploads and longer script runtimes
       client_max_body_size 100m;
       client_body_timeout 60;
#Images
   location /images {
       # Separate location for images/ so .php execution won't apply
       add_header X-Content-Type-Options "nosniff";
   }
   location /images/deleted {
       # Deny access to deleted images folder
       deny all;
   }
# MediaWiki assets (usually images)
   location ~ ^/resources/(assets|lib|src) {
       try_files $uri 404;
       add_header Cache-Control "public";
       expires 7d;
   }
# Assets, scripts and styles from skins and extensions
   location ~ ^/(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 ~ ^/(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;
       rewrite ^/([^\?]*) /index.php?title=$1&$args last;
       }
}