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

Nginx Upgrading site from VB4 to XF2 and can't get the redirect to work

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by ElChorizo, Jun 6, 2021.

  1. ElChorizo

    ElChorizo Premium Member Premium Member

    15
    1
    3
    Apr 29, 2021
    Ratings:
    +2
    Local Time:
    5:59 PM
    1.19.10
    10.3.28
    I've upgraded a site from domain.com/forum/ running on vb4 to domain.com/ --- I've followed the instructions and put the rewrite version of index.php in the /forum/ sub directory but I can't get the nginx portion of the config to work properly.... it can never find the thread.

    I've tried all the suggestions here: XenForo Redirects for vBulletin

    I commented out this code as it didn't work:

    Code:
    #  location /forum/ {
    #  include /usr/local/nginx/conf/503include-only.conf;
    #  try_files $uri $uri/ /forum/index.php?$uri&$args;
    #  }
    
    Any ideas?

     
  2. eva2000

    eva2000 Administrator Staff Member

    47,461
    10,759
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,715
    Local Time:
    9:59 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    See XenForo Redirects for vBulletin and his solution at XenForo Redirects for vBulletin
     
  3. ElChorizo

    ElChorizo Premium Member Premium Member

    15
    1
    3
    Apr 29, 2021
    Ratings:
    +2
    Local Time:
    5:59 PM
    1.19.10
    10.3.28
    I already have that in my site.com.ssl.conf file in the normal place --- it is needed for pretty URL's. If I need to add it into another section other than the location / stanza, where else would it go?

    Code:
    #x# HTTPS-DEFAULT
     server {
    
       server_name coffeeforums.com www.coffeeforums.com;
       return 302 https://coffeeforums.com$request_uri;
       root /home/nginx/domains/coffeeforums.com/public;
       include /usr/local/nginx/conf/staticfiles.conf;
     }
    
    
    server {
      listen 443 ssl http2;
      server_name coffeeforums.com www.coffeeforums.com;
    
      include /usr/local/nginx/conf/ssl/coffeeforums.com/coffeeforums.com.crt.key.conf;
      include /usr/local/nginx/conf/ssl_include.conf;
    
      # cloudflare authenticated origin pull cert community.centminmod.com/threads/13847/
      #ssl_client_certificate /usr/local/nginx/conf/ssl/cloudflare/coffeeforums.com/origin.crt;
      #ssl_verify_client on;
    
    
    
      # mozilla recommended
      ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
      ssl_prefer_server_ciphers   on;
      #add_header Alternate-Protocol  443:npn-spdy/3;
    
      # before enabling HSTS line below read centminmod.com/nginx_domain_dns_setup.html#hsts
      #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
      #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";
      #add_header Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()";
      #spdy_headers_comp 5;
      ssl_buffer_size 1369;
      ssl_session_tickets on;
    
      # enable ocsp stapling
      resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 valid=10m;
      resolver_timeout 10s;
      ssl_stapling on;
      ssl_stapling_verify on;
    
    # 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;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/coffeeforums.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/coffeeforums.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/coffeeforums.com/autoprotect-coffeeforums.com.conf;
      root /home/nginx/domains/coffeeforums.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 ~* ^/forum/*/(/.+\.(js|css|jpg|php|html))$ {
    #    alias /forums/index.php$1;
    #}
    
    #  location ~ ^/forum/$ {
    #  try_files $uri $uri/ /forum/index.php?$uri&$args;
    #  }
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
      try_files $uri $uri/ /index.php?$uri&$args;
    
    
    # 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;
    
      }
    
      include /usr/local/nginx/conf/php.conf;
    
      include /usr/local/nginx/conf/pre-staticfiles-local-coffeeforums.com.conf;
      include /usr/local/nginx/conf/pre-staticfiles-global.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    Edit: I added this code and it doesn't work either.

    Code:
    location /forum/ {
    try_files $uri /index.php?$uri&$args;
    }
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    47,461
    10,759
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,715
    Local Time:
    9:59 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    that goes in your
    /usr/local/nginx/conf/php.conf include file for *.php requests. If you have other non forum sites on server, you can make a copy of /usr/local/nginx/conf/php.conf and use that in your forum nginx vhost instead and edit that copy
     
  5. ElChorizo

    ElChorizo Premium Member Premium Member

    15
    1
    3
    Apr 29, 2021
    Ratings:
    +2
    Local Time:
    5:59 PM
    1.19.10
    10.3.28
    I added that to php-coffee.conf and told coffeeforums.com to use that instead of php.conf -- with the following code:

    Code:
    location ~ [^/]\.php(/|$) {
      include /usr/local/nginx/conf/503include-only.conf;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }
        try_files $uri /forum/index.php?$uri&$args;
        #fastcgi_keep_conn on;
        fastcgi_pass dft_php;
        #fastcgi_pass   127.0.0.1:9000;
        #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME    $request_filename;
        #fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;
    
    The old directory was /forum/ and the new directory is docroot, but I put the modified index.php that came with the redirect script in the /forum/ directory with the correct XF2 path... these types of URL's still error out:

    http://www.coffeeforums.com/forum/caffeine-health/2401-dry-mouth.html

    http://www.coffeeforums.com/forum/latte-art/3249-coffee-lovers.html

    http://www.coffeeforums.com/forum/coffee-roasters/7308-data-loggers.html