Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

4.5 KB
Raw Blame
upstream php {
    #server unix:/var/run/php/php-fpm.sock;
    #server unix:/var/run/php/php8.6-fpm.sock;    #debian/ubuntu versioned socket
    #server unix:/var/run/php-fpm86/php-fpm.pid;  #alpine
    server 127.0.0.1:9000;                       #tcp
}

server {
    listen 0.0.0.0:80;

    #listen 80 server;
    #listen [::]:80 server;
    #listen 443 ssl http2;
    #listen [::]:443 ssl http2;

    #ssl_certificate /etc/letsencrypt/live/vvveb.com/fullchain.pem;
    #ssl_certificate_key /etc/letsencrypt/live/vvveb.com/privkey.pem;
    #ssl_session_cache shared:SSL:20m;
    #ssl_session_timeout 10m;
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;
    #ssl_ciphers 'ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5';
    
    #error_log  /var/log/nginx/error.log;
    #access_log /var/log/nginx/access.log;

    #always use public folder as root for security    
    root /var/www/html/public;

    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/manifest+json application/javascript text/xml application/xml application/xml+rss application/rss+xml application/atom+xml text/javascript image/svg+xml;

    #charset utf-8;

    #security headers
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";
    add_header Referrer-Policy "strict-origin-when-cross-origin";

    #hide the php version from responses
    fastcgi_hide_header X-Powered-By;

    #allow enough time for long running admin requests (imports, backups)
    fastcgi_read_timeout 900;

    set $skip_cache 0;
    set $cache_uri $request_uri;

    #urls with a query string should always go to php
    if ($query_string != "") {
        set $skip_cache 1;
        set $cache_uri "";
    }

    #don't cache uris containing the following segments
    if ($request_uri ~* "/admin/|/user/|/cart/|/feed/|index.php|sitemap(_index)?.xml") {
        set $skip_cache 1;
        set $cache_uri "";
    }

    #don't use the cache for logged in users or if products are in cart
    if ($http_cookie ~* "nocache|cart|user|admin") {
        set $skip_cache 1;
        set $cache_uri "";
    }

    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
        set $skip_cache 1;
        set $cache_uri null;
    }

    index index.php index.html;
    error_page 404 /index.php;

    #static files
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    #add domain to sitemaps for multisite
    location = /robots.txt {
        log_not_found off;
        access_log off;
        try_files $uri /index.php$is_args$args;
    }

    #deny hidden files except .well-known (acme challenges)
    location ~ /\.(?!well-known).* {
        deny all;
    }

    #static files
    location ~* "\.(?!php)(\w{2,5})$" {
        expires max;
        log_not_found off;
        access_log off;
        sendfile on;
        sendfile_max_chunk 1m;
        tcp_nopush on;
        fastcgi_hide_header "Set-Cookie";

        #try_files $uri =404;
    }

    location / {
        default_type text/html;
        index index.php index.html;
        try_files /page-cache/$host$cache_uri /page-cache/$host$cache_uri/index.html $uri $uri/ /index.php$is_args$args;
        #try_files $uri $uri/ /index.php$is_args$args;

        #cache debug
        #add_header "uri" $cache_uri;
        #add_header "skip_cache" $skip_cache;

        location ~ /vadmin-.+/index\.php {
            include fastcgi.conf;
            fastcgi_pass php;
        }

        location = /admin/index.php {
            include fastcgi.conf;
            fastcgi_pass php;
        }

        location = /install/index.php {
            include fastcgi.conf;
            fastcgi_pass php;
        }

        location ~ \.php$ {
            rewrite ^ /index.php last;
        }

        location = /index.php {
            include fastcgi.conf;
            fastcgi_pass php;
            fastcgi_read_timeout 900;
            include fastcgi_params;
            #uncomment fastcgi_cache to enable fastcgi cache, this should not be necessary
            #unless you set the path to a memory mapped location for even faster cache

            #fastcgi_cache VCACHE;
            #fastcgi_cache_bypass $skip_cache;
            #fastcgi_no_cache $skip_cache;
            #fastcgi_cache_valid 30m;
            #add_header X-VCache $upstream_cache_status;
        }
    }
}