Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

7.0 KB
Raw Blame
# Vvveb nginx configuration
#
# Setup:
#   1. replace /var/www/vvveb/public with your vvveb website public folder
#   2. replace vvveb.com with your domain
#   3. copy this file to /etc/nginx/sites-available/vvveb
#   4. sudo ln -s /etc/nginx/sites-available/vvveb /etc/nginx/sites-enabled/vvveb
#      or for apline linux /etc/nginx/httpd.d/default.conf
#   5. sudo nginx -t && sudo systemctl reload nginx

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
}

upstream php86 {
    server unix:/var/run/php/php8.6-fpm.sock;
    #server unix:/var/run/php-fpm86.pid;#alpine
    #server 127.0.0.1:9000;
}



#use fastcgi cache if you want an even faster cache by mapping to memory otherwise leave it disabled to use the default try_files file cache
#fastcgi_cache_path /var/run/nginx-vvveb_cache levels=1:2 keys_zone=VCACHE:100m inactive=30m;
#fastcgi_cache_key "$scheme$request_method$host$request_uri";
#fastcgi_cache_use_stale error timeout invalid_header http_500;

server {
    #always use public folder as root for security
    root /var/www/vvveb/public;

    #replace vvveb.com with your domain
    server_name *.vvveb.com vvveb.com;

    #don't advertise the nginx version
    server_tokens off;

    #max upload size, keep in sync with php.ini upload_max_filesize/post_max_size
    client_max_body_size 64m;

    #listen 80;
    #listen [::]:80;

    #listen 443 ssl;
    #listen [::]:443 ssl;
    #http2 on;                                    #nginx >= 1.25.1, on older versions use "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 1d;
    #ssl_session_tickets off;

    #disable deprecated protocols, keep only tls 1.2 and 1.3
    #ssl_protocols TLSv1.2 TLSv1.3;
    #ssl_prefer_server_ciphers off;
    #mozilla intermediate cipher suite (tls 1.2 ciphers, tls 1.3 suites are used automatically)
    #ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';

    #ocsp stapling
    #ssl_stapling on;
    #ssl_stapling_verify on;

    #enable after confirming https works, avoid on shared subdomains (include subdomains optional)
    #add_header Strict-Transport-Security "max-age=31536000" always;

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

    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
    #note: nginx replaces all inherited add_header directives with local ones,
    #so if you add any add_header directive inside a location below remember to copy these
    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)
    #must come before the static files location: regex locations match in
    #file order and the static pattern would otherwise serve dotfiles like
    #.env or .user.ini whose extension happens to be 2-5 chars long
    location ~ /\.(?!well-known).* {
        deny all;
    }

    #static files, served directly with far future caching
    #{2,5} covers two letter extensions like .js too
    #(?!php) leaves php files to the interpreter
    location ~* "\.(?!php)(\w{2,5})$" {
        expires max;
        log_not_found off;
        access_log off;
        sendfile on;
        sendfile_max_chunk 1m;
        tcp_nopush on;

        #uncomment to serve only files that exist, otherwise missing files fall back to the app
        #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, remember that adding add_header here disables the security headers above
        #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;
        }

        #route all other php requests through the front controller
        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;
        }
    }
}