Nginx: Difference between revisions

From neuromatch
(Created page with "Up to: Part Of::Wiki <syntaxhighlight lang="nginx"> server { server_name wiki.neuromatch.social; root /var/www/html/mediawiki; index index.php; error_log /var/log/nginx/mediawiki.error; access_log /var/log/nginx/mediawiki.access; location / { try_files $uri $uri/ /index.php; } location @rewrite { rewrite ^/(.*)$ /index.php; } location ^~ /maintenance/ { return 403; } location ~ /\.ht {...")
 
No edit summary
Line 48: Line 48:


}
}
# ---------------------------------
# redirect http -> https
# ---------------------------------


server {
server {
Line 63: Line 68:
}
}


# ---------------------------------
# ---------------------------------
# ---------------------------------
# ---------------------------------
# redirects from olde wiki domain
# redirects from olde wiki domain
# ---------------------------------
# ---------------------------------
# ---------------------------------
# ---------------------------------



Revision as of 23:09, 12 October 2023

Up to: Wiki

server {
    server_name wiki.neuromatch.social;

    root /var/www/html/mediawiki;
    index index.php;

    error_log /var/log/nginx/mediawiki.error;
    access_log /var/log/nginx/mediawiki.access;

    location / {
        try_files $uri $uri/ /index.php;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php;
    }

    location ^~ /maintenance/ {
        return 403;
    }


    location ~ /\.ht {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        include snippets/fastcgi-php.conf;
    }

    location /rest.php {
        try_files $uri $uri/ /rest.php?$args;
    }


    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/wiki.neuromatch.social/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/wiki.neuromatch.social/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


# ---------------------------------
# redirect http -> https
# ---------------------------------

server {
    if ($host = wiki.neuromatch.social) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name wiki.neuromatch.social;

    listen 80;
    listen [::]:80;
    return 404; # managed by Certbot

}

# ---------------------------------
# ---------------------------------
# ---------------------------------
# redirects from olde wiki domain
# ---------------------------------
# ---------------------------------
# ---------------------------------

server {
    if ($host = wiki.neuromatch.io) {
        return 301 https://wiki.neuromatch.social$request_uri;
    }

    server_name wiki.neuromatch.io;

    listen 80;
    return 404;

}

server {
    if ($host = wiki.neuromatch.io) {
        return https://wiki.neuromatch.social$request_uri;
    }

    server_name wiki.neuromatch.io;
    listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/wiki.neuromatch.io/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/wiki.neuromatch.io/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}