Nginx.Conf Xenforo Problem

melbourne

New member
Hello,

I've installed nginx. xenforo seo setting, but I could not. Can you help?

Thanks.
Code:
user              nginx nginx;
worker_processes  1;
worker_priority -10;

worker_rlimit_nofile 51200;
timer_resolution 100ms;
error_log        logs/error.log;
pid              logs/nginx.pid;
events {
    worker_connections  1024;
    use epoll;
    #multi_accept on;
}
http {
log_format      main    '$remote_addr - $remote_user [$time_local] $request '
                '"$status" $body_bytes_sent "$http_referer" '
                '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
                ' "$connection" "$connection_requests" "$request_time"';
access_log logs/access.log combined buffer=32k;
    index  index.php index.html index.htm;
    include      mime.types;
    default_type  application/octet-stream;
    charset utf-8;
        sendfile on;
        #sendfile_max_chunk 1m;
        tcp_nopush  on;
        tcp_nodelay off;
        server_tokens off;
        server_name_in_redirect off;
      
        keepalive_timeout  10;
        keepalive_disable msie6;
    gzip on;
    gzip_vary  on;
    gzip_disable "MSIE [1-6]\.";
        gzip_static on;
        gzip_min_length  1400;
        gzip_buffers      32 8k;
        gzip_http_version 1.0;
        gzip_comp_level 5;
        gzip_proxied    any;
        gzip_types text/plain text/css text/xml application/javascript  application/x-javascript application/xml application/xml+rss;
client_body_buffer_size 256k;
client_body_in_file_only off;
client_body_timeout 60s;
client_header_buffer_size 256k;
## how long a connection has to complete sending
## it's headers for request to be processed
client_header_timeout  20s;
client_max_body_size 1024k;
connection_pool_size  512;
directio  4m;
ignore_invalid_headers on;    
large_client_header_buffers 8 256k;
output_buffers  8 256k;
postpone_output  1460;
proxy_temp_path  /tmp/nginx_proxy/;
request_pool_size  32k;
reset_timedout_connection on;
send_timeout    60s;
server_names_hash_bucket_size 64;
# for nginx proxy backends to prevent redirects to backend port
# port_in_redirect off;
open_file_cache max=5000 inactive=30s;
open_file_cache_valid 120s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
open_log_file_cache max=1024 inactive=30s min_uses=2;
## limit number of concurrency connections per ip to 16
## add to your server {} section the next line
## limit_conn limit_per_ip 16;
## uncomment below line allows 500K sessions
# limit_conn_log_level error;
#######################################
# use limit_zone for Nginx <v1.1.7 and lower
# limit_zone $binary_remote_addr zone=limit_per_ip:16m;
#######################################
# use limit_conn_zone for Nginx >v1.1.8 and higher
# limit_conn_zone $binary_remote_addr zone=limit_per_ip:16m;
#######################################
include /usr/local/nginx/conf/conf.d/*.conf;
}
 
Hello,

I've installed nginx. xenforo seo setting, but I could not. Can you help?

Thanks.
How are you getting the php files read? Where did you get that from?

I have this (and have to) in my nginx forum definition
Code:
    # use fastcgi for all php files
        location ~ \.php$ {
        # Zero-day exploit defense.
        # http://forum.nginx.org/read.php?2,88845,page=3
        try_files $uri /index.php =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
 
Like Tracy Perry said you're missing whatever handles your .php files, like Fast-CGI or FPM, etc.

You need this also for SEO settings to work:

Code:
location /xf/ {
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    index index.php index.html;
}

location /xf/internal_data/ {
    internal;
}
location /xf/library/ {
      internal;
}
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

Those are the minimum, you can configure it further for better peformance/security.
 
I have very big problem. I changed but restart error.

Error
Code:
nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:20
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
 
I have very big problem. I changed but restart error.

Error
Code:
nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:20
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
Here is the one I use for my one domain forum
Code:
server {
    listen 80;
    server_name www.bogboys.com;
    return 301 http://bogboys.com$uri;
}

server {
    listen 80;
    server_name bogboys.com;

rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
    error_log /var/log/nginx/bogboys-error.log warn;
    access_log /var/log/nginx/bogboys-access.log;
    root /var/www/bogboys;
    #end changes needed to begin

    location / {
        #This sends everything through index.php and keeps the appended
            #query string intact.
            try_files $uri $uri/ /index.php?$uri&$args;
            index index.html index.htm index.php;
           rewrite /(robots.txt)$ /robots.php last;

    #gzip it, gzip it good
      gzip                    on;
      gzip_http_version      1.1;
      gzip_vary              on;
      gzip_min_length        1100;
      gzip_buffers            64 8k;
      gzip_comp_level        2;
      gzip_proxied            any;
      gzip_types              image/png image/gif image/jpeg image/jpg text/xml text/plain text/css application/json application/x-javascript application/vnd.ms-fontobject
      gzip_disable "MSIE [1-6]\.(?!.*SV1)";
        }


      # use fastcgi for all php files
        location ~ \.php$ {
        # Zero-day exploit defense.
        # http://forum.nginx.org/read.php?2,88845,page=3
        try_files $uri /index.php =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;


        }
# Feed
        location ~* \.(?:rss|atom)$ {
            expires 1h;
            add_header Cache-Control "public";
    }

# Media: images, icons, video, audio, HTC
        location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
            expires 1M;
            access_log off;
            add_header Cache-Control "public";
    }

# CSS and Javascript
        location ~* \.(?:css|js)$ {
            expires 1y;
            access_log off;
            add_header Cache-Control "public";
    }

# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
        location ~* \.(?:ttf|ttc|otf|eot|woff|font.css)$ {
            expires 1M;
            access_log off;
            add_header Cache-Control "public";
    }

        #protect the innocent
        location ~ ^/community/(internal_data|library)/(.*)$ {
        internal;
        }

        # deny access to apache .htaccess files
        location ~ /\.ht
        {
        deny all;
    }
}
 
Last edited:
Here is the one I use for my one domain forum
Code:
server {
    listen 80;
    server_name www.bogboys.com;
    return 301 http://bogboys.com$uri;
}

server {
    listen 80;
    server_name bogboys.com;
rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
    error_log /var/log/nginx/bogboys-error.log warn;
    access_log /var/log/nginx/bogboys-access.log;
    root /var/www/bogboys;
    #end changes needed to begin

location /nginx_status {
                stub_status on;
                access_log  off;
                allow 127.0.0.1;
                deny all;
        }
location /internal_data/ {
    internal;
    }
    location /library/ {
          internal;
          }
    location / {
      #This sends everything through index.php and keeps the appended
            #query string intact.
            try_files $uri $uri/ /index.php?$uri&$args;
            index index.html index.htm index.php;
          rewrite /(robots.txt)$ /robots.php last;
    #gzip it, gzip it good
      gzip                    on;
      gzip_http_version      1.1;
      gzip_vary              on;
      gzip_min_length        1100;
      gzip_buffers            64 8k;
      gzip_comp_level        2;
      gzip_proxied            any;
      gzip_types              image/png image/gif image/jpeg image/jpg text/xml text/plain text/css application/json application/x-javascript application/vnd.ms-fontobject
      gzip_disable "MSIE [1-6]\.(?!.*SV1)";
        }
      # use fastcgi for all php files
        location ~ \.php$ {
        # Zero-day exploit defense.
        # http://forum.nginx.org/read.php?2,88845,page=3
        try_files $uri /index.php =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
        }
# Feed
        location ~* \.(?:rss|atom)$ {
            expires 1h;
            add_header Cache-Control "public";
    }
# Media: images, icons, video, audio, HTC
        location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
            expires 1M;
            access_log off;
            add_header Cache-Control "public";
    }
# CSS and Javascript
        location ~* \.(?:css|js)$ {
            expires 1y;
            access_log off;
            add_header Cache-Control "public";
    }
# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
        location ~* \.(?:ttf|ttc|otf|eot|woff|font.css)$ {
            expires 1M;
            access_log off;
            add_header Cache-Control "public";
    }

        # deny access to apache .htaccess files
        location ~ /\.ht
        {
        deny all;
    }
}

Error

nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:1
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

Dont work.
 
Error

nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:1
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

Dont work.
What version of nginx... it's working fine with that exact host setup on my current Debian 7.0 running nginx 1.4.1.
When you say you installed it, did you compile it or did you use a repository version? What OS (Debian, centOS, Ubuntu) are you using?
 
What version of nginx... it's working fine with that exact host setup on my current Debian 7.0 running nginx 1.4.1.
When you say you installed it, did you compile it or did you use a repository version? What OS (Debian, centOS, Ubuntu) are you using?
I use Centos 6.3 and Centminmod installer.
 
I think I may have found an error in my example. I had taken a section out that pertains to my phpmyadmin setup protection and think I cut one to many "}" out.
Change this segment
Code:
rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
    error_log /var/log/nginx/bogboys-error.log warn;
    access_log /var/log/nginx/bogboys-access.log;
    root /var/www/bogboys;
    #end changes needed to begin
to this
Code:
rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
    error_log /var/log/nginx/bogboys-error.log warn;
    access_log /var/log/nginx/bogboys-access.log;
    root /var/www/bogboys;
    #end changes needed to begin
}
and see if it works.
 
I think I may have found an error in my example. I had taken a section out that pertains to my phpmyadmin setup protection and think I cut one to many "}" out.
Change this segment
Code:
rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
    error_log /var/log/nginx/bogboys-error.log warn;
    access_log /var/log/nginx/bogboys-access.log;
    root /var/www/bogboys;
    #end changes needed to begin
to this
Code:
rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
    error_log /var/log/nginx/bogboys-error.log warn;
    access_log /var/log/nginx/bogboys-access.log;
    root /var/www/bogboys;
    #end changes needed to begin
}
and see if it works.
the problem did not improve. still continues, I do not know why.
 
the problem did not improve. still continues, I do not know why.
@melbourne I've edited my original full example. I just tested it on my dedicated server using nginx -t and it checks clear. Try recopying all that to the file you are using, editing the paths and the names to reflect your setup.
 
I use Centos 6.3 and Centminmod installer.

Which version of Centmin Mod used http://centminmod.com/changelog.html ?

Did you follow Xenforo and Centmin Mod setup for your domain's VHOST file as per http://centminmod.com/nginx_configure.html ? Specifically http://centminmod.com/nginx_configure_xenforo_seo_friendly_urls.html

Your domain's vhost as per http://centminmod.com/nginx_domain_dns_setup.html when you run menu option #2 would be located at
  • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
  • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
  • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
With Centmin Mod VHOST entries are not in nginx.conf but their own vhost files i.e. /usr/local/nginx/conf/conf.d/yourdomain.com.conf

run centmin.sh script and menu option #2 first to setup your domain Nginx vhost as per instructions at http://centminmod.com/nginx_domain_dns_setup.html

Code:
--------------------------------------------------------
Centmin Mod 1.2.3-eva2000.03 - http://centminmod.com
--------------------------------------------------------
                  Centmin Mod Menu               
--------------------------------------------------------
1).  Centmin Install
2).  Add Nginx vhost domain
3).  NSD setup domain name DNS
4).  Nginx Upgrade / Downgrade
5).  PHP Upgrade / Downgrade
6).  XCache Re-install
7).  APC Cache Re-install
8).  XCache Install
9).  APC Cache Install
10). Memcached Server Re-install
11). MariaDB 5.2.x Branch Upgrade Only
12). MariaDB 5.2.x to MariaDB 5.5 YUM upgrade
13). Install ioping.sh vbtechsupport.com/1239/
14). SELinux disable
15). Install/Re-install imagick PHP Extension
16). Change SSHD Port Number
17). Multi-thread compression: pigz,pbzip2,lbzip2,p7zip etc
18). Suhosin PHP Extension install
19). Install FFMPEG and FFMPEG PHP Extension
20). NSD Re-install
21). Exit
--------------------------------------------------------
Enter option [ 1 - 21 ]
--------------------------------------------------------

I use Centmin Mod for my Xenforo forums without problems.. I think a few other xenforo users also use Centmin Mod as well :)
 
Last edited:
  • Like
Reactions: rdn
Which version of Centmin Mod used http://centminmod.com/changelog.html ?

Did you follow Xenforo and Centmin Mod setup for your domain's VHOST file as per http://centminmod.com/nginx_configure.html ? Specifically http://centminmod.com/nginx_configure_xenforo_seo_friendly_urls.html

Your domain's vhost as per http://centminmod.com/nginx_domain_dns_setup.html when you run menu option #2 would be located at
  • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
  • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
  • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
With Centmin Mod VHOST entries are not in nginx.conf but their own vhost files i.e. /usr/local/nginx/conf/conf.d/yourdomain.com.conf

run centmin.sh script and menu option #2 first to setup your domain Nginx vhost as per instructions at http://centminmod.com/nginx_domain_dns_setup.html

Code:
--------------------------------------------------------
Centmin Mod 1.2.3-eva2000.03 - http://centminmod.com
--------------------------------------------------------
                  Centmin Mod Menu              
--------------------------------------------------------
1).  Centmin Install
2).  Add Nginx vhost domain
3).  NSD setup domain name DNS
4).  Nginx Upgrade / Downgrade
5).  PHP Upgrade / Downgrade
6).  XCache Re-install
7).  APC Cache Re-install
8).  XCache Install
9).  APC Cache Install
10). Memcached Server Re-install
11). MariaDB 5.2.x Branch Upgrade Only
12). MariaDB 5.2.x to MariaDB 5.5 YUM upgrade
13). Install ioping.sh vbtechsupport.com/1239/
14). SELinux disable
15). Install/Re-install imagick PHP Extension
16). Change SSHD Port Number
17). Multi-thread compression: pigz,pbzip2,lbzip2,p7zip etc
18). Suhosin PHP Extension install
19). Install FFMPEG and FFMPEG PHP Extension
20). NSD Re-install
21). Exit
--------------------------------------------------------
Enter option [ 1 - 21 ]
--------------------------------------------------------

I use Centmin Mod for my Xenforo forums without problems.. I think a few other xenforo users also use Centmin Mod as well :)
Me as well, and I think you have more knowledge on centminmod :)
Where did you garb those url's?


I haven't seen that before :D
 
Top Bottom