Note that there are some explanatory texts on larger screens.

plurals
  1. POnginx add_after_body and if
    primarykey
    data
    text
    <p>Nginx is saying that "add_after_body" isn't allowed in an "if" statement, is there any alternative? Here is the current config</p> <pre><code>if ($request_uri ~* ^/(home|page1|page2|page4)(.*+)\.html$) { add_after_body /stats.html; } </code></pre> <p>The same problem occurs if I put the if block in a location block instead</p> <p>Here's the error:</p> <pre><code>Reloading nginx configuration: nginx: [emerg] "add_after_body" directive is not allowed here in /etc/nginx/sites-enabled/default:22 nginx: configuration file /etc/nginx/nginx.conf test failed </code></pre> <p>Here's the complete server block:</p> <pre><code>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&amp;page=$2; rewrite ^/thread-([0-9]+)\.html$ /showthread.php?tid=$1; rewrite ^/thread-([0-9]+)-page-([0-9]+)\.html$ /showthread.php?tid=$1&amp;page=$2; rewrite ^/thread-([0-9]+)-lastpost\.html$ /showthread.php?tid=$1&amp;action=lastpost; rewrite ^/thread-([0-9]+)-nextnewest\.html$ /showthread.php?tid=$1&amp;action=nextnewest; rewrite ^/thread-([0-9]+)-nextoldest\.html$ /showthread.php?tid=$1&amp;action=nextoldest; rewrite ^/thread-([0-9]+)-newpost\.html$ /showthread.php?tid=$1&amp;action=newpost; rewrite ^/thread-([0-9]+)-post-([0-9]+)\.html$ /showthread.php?tid=$1&amp;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&amp;uid=$1; rewrite ^/calendar-([0-9]+)\.html$ /calendar.php?calendar=$1; rewrite ^/calendar-([0-9]+)-year-([0-9]+)\.html$ /calendar.php?action=yearview&amp;calendar=$1&amp;year=$2; rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ /calendar.php?calendar=$1&amp;year=$2&amp;month=$3; rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ /calendar.php?action=dayview&amp;calendar=$1&amp;year=$2&amp;month=$3&amp;day=$4; rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+)\.html$ /calendar.php?action=weekview&amp;calendar=$1&amp;week=$2; rewrite ^/event-([0-9]+)\.html$ /calendar.php?action=event&amp;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/; } </code></pre> <p>I've tried putting the statement both inside the <code>location</code> statement, and outside (<code>add_after_body</code> works without an <code>if</code> statement both inside a <code>location</code> block or <code>server</code> block)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload