This is an old revision of the document!


Nginx

Example Server Blocks

Note: These are messy and need cleaned up. Don't blindly copy-paste may be errors.


Example Server Blocks

React

server {
    listen 80 default_server;
    server_name www.schedukal.ml schedukal.ml;
    access_log /var/log/nginx/access-SITENAME.log;
 
    root /web/schedukal.ml;
    index index.php index.html;
 
    location / {
        try_files $uri /index.html;
    }
 
    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
 
    location ~ /\.(?!well-known).*{
        deny all;
    }
    error_page 404 /404.html;
 
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/kalen.pw/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/kalen.pw/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
}

Vue

server {
    listen 80;
    listen 443 ssl; # managed by Certbot
    server_name www.kalen.pw kalen.pw;
   access_log /var/log/nginx/access-SITENAME.log;
 
    root /web/kalen.pw;
    index index.php index.html;    
 
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
 
    error_page 404 /404.html;
    ssl_certificate /etc/letsencrypt/live/kalen.pw/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/kalen.pw/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
 
    #if ($scheme != "https") {
    #    return 301 https://$host$request_uri;
    #} # managed by Certbot
}