Nginx говорит, что add_after_body не допускается в выражении if, есть ли альтернатива?Вот текущая конфигурация
if ($request_uri ~* ^/(home|page1|page2|page4)(.*+)\.html$) {
add_after_body /stats.html;
}
Та же проблема возникает, если вместо этого поместить блок if в блок местоположения
.полный блок сервера:
server {
listen 80; ## listen for ipv4
#listen [::]:80; ## listen for ipv6
server_name .mydoma.in;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml;
gzip_disable "MSIE [1-6]\.";
gzip_comp_level 4;
#if ($request_uri ~* ^/(forum|thread|post|announcement|user|calendar|event|top10)(.*+)\.html$) {
# add_after_body /stats.html;
#}
location / {
index index.html index.htm index.php;
#MyBB Config
rewrite ^/forum-([0-9]+)\.html$ /forumdisplay.php?fid=$1;
rewrite ^/forum-([0-9]+)-page-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2;
rewrite ^/thread-([0-9]+)\.html$ /showthread.php?tid=$1;
rewrite ^/thread-([0-9]+)-page-([0-9]+)\.html$ /showthread.php?tid=$1&page=$2;
rewrite ^/thread-([0-9]+)-lastpost\.html$ /showthread.php?tid=$1&action=lastpost;
rewrite ^/thread-([0-9]+)-nextnewest\.html$ /showthread.php?tid=$1&action=nextnewest;
rewrite ^/thread-([0-9]+)-nextoldest\.html$ /showthread.php?tid=$1&action=nextoldest;
rewrite ^/thread-([0-9]+)-newpost\.html$ /showthread.php?tid=$1&action=newpost;
rewrite ^/thread-([0-9]+)-post-([0-9]+)\.html$ /showthread.php?tid=$1&pid=$2;
rewrite ^/post-([0-9]+)\.html$ /showthread.php?pid=$1;
rewrite ^/announcement-([0-9]+)\.html$ /announcements.php?aid=$1;
rewrite ^/user-([0-9]+)\.html$ /member.php?action=profile&uid=$1;
rewrite ^/calendar-([0-9]+)\.html$ /calendar.php?calendar=$1;
rewrite ^/calendar-([0-9]+)-year-([0-9]+)\.html$ /calendar.php?action=yearview&calendar=$1&year=$2;
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ /calendar.php?calendar=$1&year=$2&month=$3;
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ /calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+)\.html$ /calendar.php?action=weekview&calendar=$1&week=$2;
rewrite ^/event-([0-9]+)\.html$ /calendar.php?action=event&eid=$1;
rewrite ^/sitemap\-([^./]+)\.xml$ /misc.php?google_seo_sitemap=$1;
#if ($request_uri ~* "^/(forum|thread|post|announcement|user|calendar|event|top10)") {
# add_after_body /stats.html;
#}
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
#expires 1M;
# Static assets
location ~* ^.+\.(manifest|appcache)$ {
expires -1;
}
# Set expires max on static file types
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
expires max;
access_log off;
}
# opt-in to the future
add_header "X-UA-Compatible" "IE=Edge,chrome=1";
location = /50x/ {
random_index on;
}
error_page 500 502 503 504 /50X/;
}
Я пытался поместить оператор как внутри оператора location
, так и снаружи (add_after_body
работает без оператора if
внутри блока location
или server
блок)