# cache condition variable
set $usecache "";
if ($is_global_cache = 1) { set $usecache "${usecache}A"; }
# main config without processing cache pages
include conf.d/bitrix_general.conf;
# php file processing
location ~ \.php$ {
set $cache_file "bitrix/html_pages$general_key@$args.html";
# test file conditions
if (-f "$docroot/bitrix/html_pages/.enabled") { set $usecache "${usecache}B"; }
if (-f "$docroot/$cache_file") { set $usecache "${usecache}C"; }
# create rewrite if cache-file exists
if ($usecache = "ABC" ) { rewrite .* /$cache_file last; }
proxy_pass $proxyserver;
}
# directories page processing
location ~ /$ {
set $cache_file "bitrix/html_pages$general_key/index@$args.html";
# test file conditions
if (-f "$docroot/bitrix/html_pages/.enabled") { set $usecache "${usecache}B"; }
if (-f "$docroot/$cache_file") { set $usecache "${usecache}C"; }
# create rewrite if cache-file exists
if ($usecache = "ABC" ) { rewrite .* /$cache_file last; }
proxy_pass $proxyserver;
}
# Main location
location / {
proxy_pass $proxyserver;
}
user wwwuser;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_rlimit_nofile 10240;
events {
worker_connections 2048;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/force-download;
include conf.d/common_variables.conf;
include conf.d/composite_settings.conf;
server_names_hash_bucket_size 128;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format common '$remote_addr - - [$time_local - $upstream_response_time] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" $msec';
log_format balancer '$remote_addr - $remote_user [$time_iso8601] "$host" '
'"$request" $status $body_bytes_sent "schema: $scheme" '
'"$http_referer" "$http_user_agent" "$http_x_forwarded_for" '
'"$request_length" : "$request_time" -> $upstream_response_time';
log_format debug '$upstream_response_time,"$time_local","$remote_addr","$request",$status,$body_bytes_sent';
access_log off;
keepalive_timeout 65;
keepalive_requests 100;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
client_max_body_size 1024m;
client_body_buffer_size 26m;
# Parameters for back-end request proxy
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 8 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 10m;
# Assign default error handlers
error_page 500 502 503 504 /500.html;
error_page 404 = /404.html;
# Content compression parameters
gzip on;
gzip_disable "msie6";
gzip_proxied any;
gzip_static on;
gzip_http_version 1.0;
# gzip_types application/x-javascript application/javascript text/css;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
# add_header
include conf.d/http-add_header.conf;
# Set default website
include sites-enabled/*.conf;
# include /etc/nginx/conf.d/*.conf;
}
server {
listen 443 ssl http2;
#return 301 https://#DOMAIN#$request_uri;
server_name #DOMAIN# www.#DOMAIN#;
# enable SSL connection
include conf.d/ssl_#DOMAIN#.conf;
access_log /var/log/nginx/#DOMAIN#.access.log main;
error_log /var/log/nginx/#DOMAIN#.error.log warn;
#charset utf-8;
server_name_in_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:443;
proxy_set_header HTTPS YES;
proxy_set_header X-Forwarded-proto https;
set $proxyserver "http://127.0.0.1:8887";
set $imcontenttype "text/html; charset=utf-8";
set $docroot "/srv/www/hosts/#DOMAIN#/www";
index index.php;
root "/srv/www/hosts/#DOMAIN#/www";
# Redirect to ssl if need
if (-f /srv/www/hosts/#DOMAIN#/www.htsecure) { rewrite ^(.*)$ https://$host$1 permanent; }
# Include parameters common to all websites
include conf.d/bitrix.conf;
# Include munin and nagios web
include conf.d/server_monitor.conf;
ssl_certificate /etc/letsencrypt/live/#DOMAIN#-0001/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/#DOMAIN#-0001/privkey.pem; # managed by Certbot
}