Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

[HOWTO] Serve static content from a cookieless domain in NGINX

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
3 posts • Page 1 of 1
SS88
Posts: 336
Joined: Thu Nov 19, 2015 12:40 pm

[HOWTO] Serve static content from a cookieless domain in NGINX
  • Quote

Post by SS88 » Thu Jun 01, 2017 4:34 pm

Hey guys,

Solving that Google Pagespeed issue as well as others...

Very simply one here. For all those that know what you're doing it's a one-liner:

Code: Select all

fastcgi_hide_header "Set-Cookie";
In EVERY template (perhaps Vesta set this has default?) in the folder /usr/local/vesta/data/templates/web/nginx/php-fpm

Change:

Code: Select all

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }
To

Code: Select all

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
            fastcgi_hide_header "Set-Cookie";
        }
For example this file now looks like this: /usr/local/vesta/data/templates/web/nginx/php-fpm/wordpress.tpl

Code: Select all

server {
    listen      %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    location / {

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
            fastcgi_hide_header "Set-Cookie";
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    %backend_lsnr%;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/nginx.%domain%.conf*;
}
Top

RobertSP
Posts: 3
Joined: Mon Aug 01, 2016 6:40 am

Re: [HOWTO] Serve static content from a cookieless domain in NGINX
  • Quote

Post by RobertSP » Wed Sep 20, 2017 4:50 am

location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js|eot|otf|woff|woff2|ttf|ogg)$ {
expires max;
fastcgi_hide_header "Set-Cookie";
}
for better optimization
Top

rhyker2u
Posts: 86
Joined: Thu Jan 19, 2017 11:46 am
Contact:
Contact rhyker2u
Website

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: [HOWTO] Serve static content from a cookieless domain in NGINX
  • Quote

Post by rhyker2u » Sat Mar 17, 2018 2:22 am

thanks for the snippets!
Top


Post Reply
  • Print view

3 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password