Want to subscribe to topics you're interested in?
Become a Member

Xenforo How to enable Xenforo friendly url?

Discussion in 'Forum software usage' started by sepulchre, Mar 22, 2018.

  1. sepulchre

    sepulchre Member

    168
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    2:43 PM
    Xenforo says to do this to enable friendly url:

    Options - XenForo 2 Manual

    My conf file looks like this:


    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name www.mysite.com;
                return 301 $scheme://mysite.com$request_uri;
           }
    
    server {
     
      server_name mysite.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mysite.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/mysite.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/mysite.com/autoprotect-mysite.com.conf;
      root /home/nginx/domains/mysite.com/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
    
      # block common exploits, sql injections etc
      #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Wordpress Permalinks example
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
     
        try_files $uri $uri/ /xf/index.php?$uri&$args;
        index index.php index.html;
     
        location /install/data/ {
            internal;
        }
        location /install/templates/ {
            internal;
        }
        location /internal_data/ {
            internal;
        }
        location /library/ { #legacy
            internal;
        }
        location /src/ {
            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;
        }
      }
    
     
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
     
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    Yet it doesn't work. I don't have SSL or https (wouldn't know hot to setup these). Can someone help me out, please? What do I have to change?
     
  2. Itworx4me

    Itworx4me Active Member

    316
    29
    28
    Mar 14, 2017
    Ratings:
    +52
    Local Time:
    5:43 AM
    Nginx 1.27.4
    MariaDB 10.6.21
  3. eva2000

    eva2000 Administrator Staff Member

    55,247
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    10:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  4. sepulchre

    sepulchre Member

    168
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    2:43 PM
    Can't you just tell me what I am missing?
    Your linkings have hundreds of codes and I can't understand all of them.
     
  5. sepulchre

    sepulchre Member

    168
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    2:43 PM
    I have read those stuff, but I can't figure out what I am doing wrong.
    I don't have multiple location commands, or missing the server block.
    All looks like it should be:

    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name www.mysite.com;
                return 301 $scheme://mysite.com$request_uri;
           }
    
    server {
     
      server_name mysite.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mysite.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/mysite.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/mysite.com/autoprotect-mysite.com.conf;
      root /home/nginx/domains/mysite.com/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      location / {
        try_files $uri $uri/ /home/nginx/domains/mysite.com/public/index.php?$uri&$args;
        index index.php index.html;
      }
     
    location /home/nginx/domains/mysite.com/public/install/data/ {
        internal;
    }
    location /home/nginx/domains/mysite.com/public/install/templates/ {
        internal;
    }
    location /home/nginx/domains/mysite.com/public/internal_data/ {
        internal;
    }
    location /home/nginx/domains/mysite.com/public/library/ { #legacy
        internal;
    }
    location /home/nginx/domains/mysite.com/public/src/ {
        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;
    }
     
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
     
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    Please, this is making me crazy. What am I missing?

    I also did those in the guide with my domain:
    Code:
    touch /home/nginx/domains/newdomain.com/public/library/.autoprotect-bypass
    touch /home/nginx/domains/newdomain.com/public/internal_data/.autoprotect-bypass
    touch /home/nginx/domains/newdomain.com/public/install/data/.autoprotect-bypass
    touch /home/nginx/domains/newdomain.com/public/install/templates/.autoprotect-bypass
     
  6. eva2000

    eva2000 Administrator Staff Member

    55,247
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    10:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  7. dcg

    dcg Member

    67
    24
    8
    Oct 17, 2015
    Florida, USA
    Ratings:
    +49
    Local Time:
    8:43 AM
    1.21.x
    10.3.x
  8. eva2000

    eva2000 Administrator Staff Member

    55,247
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    10:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  9. sepulchre

    sepulchre Member

    168
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    2:43 PM
    Look at my first message, I did before without full path (although the XF manual says we should put full path), it didnt work so I thought giving full path will help. No, doesnt matter, none worked.

    And I finally got it to work.
    So, @eva2000 from your vhost generator, you should maybe delete the duplicate generated one:

    Code:
    # xenforo 2 uncomment / remove hash from next 3 lines
    #location /src/ {
    #     internal;
    #}
    
    # xenforo 2 uncomment / remove hash from next 3 lines
    #location /src/ {
    #     internal;
    #}
    As I automatically uncommented without noticing that "src" is duplicate, and this was one of the reason why it didnt work.
    2nd thing is, your generator doesn't consider if I have www redirect to non-www. Also one problem.

    And before all the generated vhost files, I think the problem is that the XF manual considerably says different things than the centminmod manual (which should be updated for xf2 btw, that was one other reason).

    For the record, for ppl who have the same issues, here is the final outcome, I removed the protection for admin.php btw:

    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name www.mysite.com;
                return 301 $scheme://mysite.com$request_uri;
           }
    
    server {
      server_name mysite.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mysite.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/mysite.com/log/error.log;
    
      root /home/nginx/domains/mysite.com/public;
    
    location / {
         index index.php index.html index.htm;
         try_files $uri $uri/ /index.php?$uri&$args;
    }
    
    location /install/data/ {
         internal;
    }
    
    location /install/templates/ {
         internal;
    }
    
    location /internal_data/ {
         internal;
    }
    
    location /library/ {
         internal;
    }
    
    location /src/ {
         internal;
    }
    
    
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      #include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    Thank you very much, nevertheless @eva2000 !
     
  10. dcg

    dcg Member

    67
    24
    8
    Oct 17, 2015
    Florida, USA
    Ratings:
    +49
    Local Time:
    8:43 AM
    1.21.x
    10.3.x
    The first one you almost had it.
    Your try files was:
    Code:
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    the uri for index.php with prefix of /xf/ is what most likely bolloxed the whole thing

    Glad you got it working
     
  11. sepulchre

    sepulchre Member

    168
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    2:43 PM
    Damn, how did I miss that? You are right, it made me crazy why it didn't work in first place.
    I blame the official xf manual for adding those prefixes. In that case I think I didn't miss it but I thought it might be needed for correct redirecting. Like kind of an internal xf thing to address it correctly, but it is actually just a plain path prefix.

    I think today I've grown 100 more gray hairs, but all good now, thank you very much.
    I hope people with same problems will learn from this, as now they should know what exactly can make problems.
     
  12. dcg

    dcg Member

    67
    24
    8
    Oct 17, 2015
    Florida, USA
    Ratings:
    +49
    Local Time:
    8:43 AM
    1.21.x
    10.3.x
    Well now you've got 100 gray hairs worth of wisdom ;)
     
  13. eva2000

    eva2000 Administrator Staff Member

    55,247
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    10:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah fixed that already must of missed it when you ran the generator :)