xenForo with nginx on Plesk 11.5

Marcus

Well-known member
I can enter domain.com and receive the xenForo start page (I got the PLESK star page instead until I removed index.html from my root). However Friendly URLs are not working.
PHP:
location / {
  try_files $uri $uri/ /index.php?$uri&$args;
  index index.php index.html;
}


location/internal_data/ {
  internal;
}

location /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;
}
 
I have this on my test VPS to work with nginx

index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$uri&$args;
 
nginx does not let me rewrite the / location, it tells me it is declaring this location already in its standard file (obviously). I installed nginx over the nginx web control panel. Hope the server management company can help me out there.
 
Should be something like:
Code:
location / {
  try_files $uri $uri/ /index.php?$uri&$args;
  index index.php index.html;
}


location /internal_data/ {
  internal;
}

location /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;
}

location<you omit space>/internal_data/ {
internal;
}
 
I get always something like this:
Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/.../conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed
 
What's in #6 is all I put in the plesk administration box. Plesk is creating a file with its contents - sometimes. Sometimes the file is empty. This is the reply from my server management team:
nginx is already running on port 80 for all domains when I get to the server

The URL you linked was loading fine

If I try to put the code you gave into /var/www/vhosts/system../conf/vhost_nginx.conf it gives an error

nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/.../conf/vhost_nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed

So I took it back out

Regards,
 
This is how it works on a Plesk server with 100% manually nginx configuration:

/etc/nginx/nginx.com
-> outcomment the inclusion lines:
# include /etc/nginx/conf.d/*.conf;

Then you can edit nginx.conf. Don't forget to "service nginx restart" after each edit.
 
Anyone using nginx on Plesk 11.5?

It is possible that there is no way to include a custom nginx.conf without workarounds:
http://forum.parallels.com/showthread.php?260814-Nginx-configuration-for-vhosts

Hi @Marcus sorry to say that plesk is a little dificul with nginx, i fight a days ago with a new server with plesk 11.5 and nginx with php-fpm, finally is working but with a manual edition of nginx files, last time that i order a server with plesk.
I post my configuration files if it helps you.

Code:
[daniel@srv01 ~]$ cat /etc/nginx/nginx.conf

user  nginx;
worker_processes  16;

events {
    worker_connections  1024;
    use epoll;
    multi_accept on;
}


http {
    include      mime.types;
    default_type  application/octet-stream;

    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    access_log off;
    sendfile        on;

    tcp_nopush on;
    tcp_nodelay on;
    #keepalive_timeout 30;
    #keepalive_requests 100000;
    #reset_timedout_connection on;
    send_timeout 300;
    #read_timeout 300;
    #connect_timeout 300;

    gzip on;
    gzip_http_version 1.0;
    gzip_comp_level 6;
    gzip_min_length 0;
    gzip_buffers 16 8k;
    gzip_proxied any;
    gzip_types text/plain text/css text/xml text/javascript application/xml application/xml+rss application/javascript application/json;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

    server_tokens off;

    index index.php index.html index.htm;

    #fastcgi_intercept_errors on;

    # limit the number of connections per single IP
    limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;

    # limit the number of requests for a given session
    limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=10r/s;

    client_body_buffer_size  128k;
    # headerbuffer size for the request header from client, its set for testing purpose
    client_header_buffer_size 3m;
    # maximum number and size of buffers for large headers to read from client request
    large_client_header_buffers 4 256k;

    include /etc/nginx/conf.d/*.conf;
}

An vhost example from /var/www/vhosts/system/site.com/conf

Code:
 cat last_nginx.conf
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.


server {
    listen x.x.x.x:80;

    server_name site.com;
    server_name www.site.com;
    server_name ipv4.site.com;


    client_max_body_size 128m;


    root "/var/www/vhosts/site.com/httpdocs";

    if ($host ~* ^site.com$) {
        rewrite ^(.*)$ http://www.site.com$1 permanent;
    }

    location @ FallBack {
    #  proxy_pass http://x.x.x.x:7080;
    #  proxy_set_header Host            $host;
    #  proxy_set_header X-Real-IP        $remote_addr;
    #  proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        access_log off;
    }



    location ~ ^/~(.+?)(/.*?\.php)(/.*)?$ {
        alias /var/www/vhosts/site.com/web_users/$1/$2;
        fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass "unix:/var/www/vhosts/system/site.com/php-fpm.sock";
        include /etc/nginx/fastcgi.conf;    }

    location ~ ^/~(.+?)(/.*)?$ {
        proxy_pass http://x.x.x.x:7080;
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        access_log off;
    }

    location ~ \.php(/.*)?$ {
        fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass 127.0.0.1:9001;
        #fastcgi_pass "unix:/var/www/vhosts/system/site.com/php-fpm.sock";
        include /etc/nginx/fastcgi.conf;    }

  # location ~ /$ {
  #    index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
  # }


    include "/var/www/vhosts/system/site.com/conf/vhost_nginx.conf";
}

Code:
 cat vhost_nginx.conf
    access_log off;
    index index.php index.html;
    limit_conn conn_limit_per_ip 10;
    limit_req zone=req_limit_per_ip burst=10 nodelay;

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

  location /internal_data/ {  internal; }
  location /library/ { internal; }


    location ~ ^/xcache {
                auth_basic "Restricted";
                auth_basic_user_file    /var/www/vhosts/system/site.com/conf/htpasswd;
    }


    location /admin.php {
                auth_basic "Restricted";
                auth_basic_user_file    /var/www/vhosts/system/site.com/conf/htpasswd;
        location ~ \.php(/.*)?$ {
                try_files $uri =404;
                fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                #fastcgi_pass "unix:/var/www/vhosts/system/site.com/php-fpm.sock";
                fastcgi_pass 127.0.0.1:9001;
                include /etc/nginx/fastcgi.conf;
                }
    }



    location ~ ^/(.*\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
        expires 1y;
    }
 
Back
Top Bottom