map $http_cookie $res_pushed {
default "false";
"~*res_pushed" "true"; # Если есть кука res_pushed с любым значением, создаём $res_pushed = true. Иначе false.
}
server{
http2_push_preload on;
location /{
if ($res_pushed = "false") {
add_header Set-Cookie "res_pushed=true; Max-Age=20; Path=/"; # Если $res_pushed = false, создаём куку
add_header Link "</style.css>;rel=preload;as=style"; # и добавляем нужный заголовок
}
}
}
map $http_cookie $res_pushed {
default "false";
"~*res_pushed" "true"; # Если есть кука res_pushed с любым значением, создаём $res_pushed = true. Иначе false.
}
server {
server_name site.su www.site.su;
charset off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/site.su/*.conf;
access_log /var/www/httpd-logs/site.su.access.log;
error_log /var/www/httpd-logs/site.su.error.log notice;
ssi on;
set $root_path /var/www/www-root/data/www/site.su;
root $root_path;
gzip on;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
http2_push_preload on;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
expires 365d;
try_files $uri $uri/ @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
access_log off;
}
return 301 https://$host:443$request_uri;
listen ip.ip.ip.ip:80;
}
server {
server_name site.su www.site.su;
ssl_certificate "/var/www/httpd-cert/www-root/narkolog24.crtca";
ssl_certificate_key "/var/www/httpd-cert/www-root/narkolog24.key";
ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
add_header Strict-Transport-Security "max-age=31536000;";
ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
charset off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/site.su/*.conf;
access_log /var/www/httpd-logs/site.su.access.log;
error_log /var/www/httpd-logs/site.su.error.log notice;
ssi on;
set $root_path /var/www/www-root/data/www/site.su;
root $root_path;
gzip on;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
http2_push_preload on;
location / {
if ($res_pushed = "false") {
add_header Set-Cookie "res_pushed=true; Max-Age=1200; Path=/"; # Если $res_pushed = false, создаём куку
add_header Link "</style.css>;rel=preload;as=style"; # и добавляем нужный заголовок
}
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
expires 365d;
try_files $uri $uri/ @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
access_log off;
}
listen ip.ip.ip.ip:443 ssl;
}