1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Nginx rewrite url problem

Discussion in 'Server Configuration and Hosting' started by Ranma1981, Jun 12, 2014.

  1. Ranma1981

    Ranma1981 Member

    Hello,

    I read the topic regard the Nginx rewrite url for Xenforo, I am trying it, but it seems doesn't work well for me. I already moved all my files and database to a new VPS, where I am testing the Xenforo forum modifying the file hosts on PC.

    But for the forum, I don't see it correctly and I have only 404 Not Found pages.

    Actually, I have Xenforo in a subdomain, called "forum".

    Here are the two codes that I tried:

    1 Code

    Code:
    server {
            listen *:80;
    
    
            server_name  forum.mysite.it ;
    
            root   /var/www/mysite.it/web/forum;
               
        location /forum/ {
        try_files $uri $uri/ /forum/index.php?$uri&$args;
        index index.php index.html;
    }
    
        location /forum/internal_data/ {
        internal;
    }
        location /forum/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;
    }
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    }
    2 Code

    Code:
    server {
            listen *:80;
    
    
            server_name  forum.mysite.it ;
    
            root   /var/www/mysite.it/web/forum;
    
    location /forum/ {
    try_files $uri $uri/ /forum/index.php?$uri&$args;
    }
    
    location /forum/data/ {
    allow 127.0.0.1;
    deny all;
    }
    
    location /forum/internal_data/ {
    allow 127.0.0.1;
    deny all;
    }
    
    location /forum/library/ {
    allow 127.0.0.1;
    deny all;
    }
    location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi.conf;
    fastcgi_intercept_errors on;
    fastcgi_ignore_client_abort on;
    }
    Can you help me to understand where is the error?

    Thanks!
     
  2. Floren

    Floren Well-Known Member

  3. Ranma1981

    Ranma1981 Member

    Hello Floren,

    I saw your link but it's a basic guide on first configuration of Nginx for Xenforo; I already did it for other my sites, actually I am having only problems to set the correct rewrite url for Nginx. I tried that two codes (the second is your), but it doesn't work well.
     
  4. Sheratan

    Sheratan Well-Known Member

    What is in nginx log? /var/log/nginx
     
  5. euantor

    euantor Well-Known Member

    In this section:

    Code:
    location /forum/ {
        try_files $uri $uri/ /forum/index.php?$uri&$args;
    }
    Change it to:

    Code:
    location / {
        try_files $uri $uri/ /index.php?$uri&$args;
    }
    Do the same for everywhere else you have /forum/ (except for the vhost root specification).
     
  6. Ranma1981

    Ranma1981 Member

    Hello,

    I removed "forum" from the section, and now I receive the error "No input file specified" on all the pages of the forum.

    Here is the actuale code:

    Code:
    server {
            listen *:80;
    
    
            server_name  forum.mysite.it ;
    
            root   /var/www/mysite.it/web/forum;
              
        location / {
        try_files            $uri $uri/ /index.php?$uri&$args;
    }
    
        location /internal_data/ {
        internal;
    }
        location /library/ {
           internal;
    }
    
    location ~ \.php$ {
        fastcgi_index            index.php;
        fastcgi_pass            127.0.0.1:9000;
        include                fastcgi.conf;
        fastcgi_intercept_errors    on;
        fastcgi_ignore_client_abort    on;
    }
    
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    }
     
  7. euantor

    euantor Well-Known Member

    Try adding the following to your php block:

    Code:
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     
  8. Ranma1981

    Ranma1981 Member

    Nothing to do, always the same errors. :mad:
     
    Last edited: Jun 13, 2014

Share This Page