Categories
blog Nginx

best – till this date!!

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    
    root /var/www/html;
    index index.php index.html;
    
    server_name tikme.space *.tikme.space;
    
    ssl_certificate /etc/letsencrypt/live/tikme.space/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/tikme.space/privkey.pem;
    
    set $subdomain "";
    if ($host ~* ^([a-z0-9-]+)\.tikme\.space$) {
        set $subdomain $1;
    }
    
    location /template/ {
        alias /var/www/html/templates/;
        expires 30d;
        add_header Cache-Control "public, immutable";
        add_header Access-Control-Allow-Origin "*";
    }
    
    location / {
        try_files /sites/$subdomain$uri $uri $uri/ /index.php?$args;
    }
    
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
    
    location ~ \.sqlite$ { deny all; }
    location ~ /\.ht { deny all; }
}