Want more timely Centmin Mod News Updates?
Become a Member

Xenforo Too many redirect!

Discussion in 'Forum software usage' started by pdinh97qng, Aug 19, 2018.

  1. pdinh97qng

    pdinh97qng Member

    40
    5
    8
    Jan 24, 2016
    Ratings:
    +9
    Local Time:
    11:24 AM
    I have a problem when trying to use XenForo and WordPress on same vhost. Using option 22 in centmin.
    Centminmod beta, Centos 7.5
    Using Xenforo on sub directory: /community
    Code (Text):
    server {
        listen xxxxx:80;
        listen [xxxxxxxx]:80;
        server_name domain.com www.domain.com;
        return 301 https://domain.com$request_uri;
        include /usr/local/nginx/conf/staticfiles.conf;
        }
    server {
        listen xxxxx:443 ssl http2;
        listen [xxxxxxxxx:443 ssl http2;
        server_name domain.com;
        return 301 https://www.domain.com$request_uri;
        include /usr/local/nginx/conf/ssl/domain.com/domain.com.crt.key.conf;
        include /usr/local/nginx/conf/ssl_include.conf;
        }
    server {
        listen xxxxxxx:443 ssl http2;
        listen [xxxxxxxxxx]:443 ssl http2;
        server_name www.domain.com;
        include /usr/local/nginx/conf/ssl/domain.com/domain.com.crt.key.conf;
        include /usr/local/nginx/conf/ssl_include.conf;
        http2_max_field_size 16k;
        http2_max_header_size 32k;
        ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305: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 Strict-Transport-Security "max-age=31536000; includeSubdomains;";
        add_header X-Xss-Protection "1; mode=block" always;
        add_header X-Content-Type-Options "nosniff" always;
        ssl_buffer_size 1369;
        ssl_session_tickets on;
        resolver 8.8.8.8 8.8.4.4 valid=10m;
        resolver_timeout 10s;
        ssl_stapling on;
        ssl_stapling_verify on;
        #include /usr/local/nginx/conf/pagespeed.conf;
        #include /usr/local/nginx/conf/pagespeedhandler.conf;
        #include /usr/local/nginx/conf/pagespeedstatslog.conf;
        access_log /home/nginx/domains/domain.com/log/access.log combined buffer=256k flush=5m;
        error_log /home/nginx/domains/domain.com/log/error.log;
        include /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf;
        root /home/nginx/domains/domain.com/public;
        include /usr/local/nginx/conf/503include-main.conf;
        include /usr/local/nginx/conf/wpincludes/domain.com/wpcacheenabler_domain.com.conf;
        location / {
            include /usr/local/nginx/conf/503include-only.conf;
            }
        location ~* /(wp-login\.php) {
            limit_req zone=xwplogin burst=1 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
            }
        location ~* /(xmlrpc\.php) {
            limit_req zone=xwprpc burst=45 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
            }
        location ~* /wp-admin/(load-scripts\.php) {
            limit_req zone=xwprpc burst=5 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
            }
        location ~* /wp-admin/(load-styles\.php) {
            limit_req zone=xwprpc burst=5 nodelay;
            include /usr/local/nginx/conf/php-wpsc.conf;
            }
        include /usr/local/nginx/conf/wpincludes/domain.com/wpsecure_domain.com.conf;
        include /usr/local/nginx/conf/php-wpsc.conf;
        location /community/ {
            try_files $uri $uri/ /index.php?$uri&$args;
            index index.php index.html;
            include /usr/local/nginx/conf/php.conf;
            }
        location /community/install/data/ {
            include /usr/local/nginx/conf/php.conf;
            internal;
            allow 127.0.0.1;
            deny all;
            }
        location /community/install/templates/ {
            include /usr/local/nginx/conf/php.conf;
            internal;
            allow 127.0.0.1;
            deny all;
            }
        location /community/internal_data/ {
            include /usr/local/nginx/conf/php.conf;
            internal;
            allow 127.0.0.1;
            deny all;
            }
        location /community/library/ {
            include /usr/local/nginx/conf/php.conf;
            internal;
            allow 127.0.0.1;
            deny all;
            }
        location /community/src/ {
            include /usr/local/nginx/conf/php.conf;
            internal;
            allow 127.0.0.1;
            deny all;
            }
        location /community/admin.php {
            include /usr/local/nginx/conf/php.conf;
            }
        include /usr/local/nginx/conf/pre-staticfiles-local-domain.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/vts_server.conf;
    }
    

     
  2. eva2000

    eva2000 Administrator Staff Member

    37,237
    8,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,524
    Local Time:
    5:24 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    if www domain is main target domain, then 1st server{} context is incorrect

    change from redirecting to non-www
    Code (Text):
    server {
       listen xxxxx:80;
       listen [xxxxxxxx]:80;
       server_name domain.com www.domain.com;
       return 301 https://domain.com$request_uri;
       include /usr/local/nginx/conf/staticfiles.conf;
       }
    

    to redirecting to www version
    Code (Text):
    server {
       listen xxxxx:80;
       listen [xxxxxxxx]:80;
       server_name domain.com www.domain.com;
       return 301 https://www.domain.com$request_uri;
       include /usr/local/nginx/conf/staticfiles.conf;
       }
    
     
  3. pdinh97qng

    pdinh97qng Member

    40
    5
    8
    Jan 24, 2016
    Ratings:
    +9
    Local Time:
    11:24 AM
    Thank you, sorry about this, I got this fixed already but the problem still occured!
     
  4. eva2000

    eva2000 Administrator Staff Member

    37,237
    8,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,524
    Local Time:
    5:24 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    What do you get for output for curl header checks in SSH where domain.com is yourdomain.com
    Code (Text):
    curl -I http://domain.com
    

    Code (Text):
    curl -I http://www.domain.com
    

    Code (Text):
    curl -I https://domain.com
    

    Code (Text):
    curl -I https://www.domain.com
    

    • If the problematic version(s) you are trying to get has a 301 HTTP status then it's probably a browser cached 301 permanent redirect issue.
    • If you use chrome in private incognito browsing session you probably have working www domain access ? if so you need to clear you browser of the 301 permanent redirect. If that works you need to clear your browsers' cache as outlined at Refreshyourcache.com - The Guide to Clear your Browser Cache!
    • That is dangers of 301 permanent redirects as they are cached in web browsers forever until cleared. 302 temp redirects are not permanent.
     
  5. pdinh97qng

    pdinh97qng Member

    40
    5
    8
    Jan 24, 2016
    Ratings:
    +9
    Local Time:
    11:24 AM
    Only this have problem!
    Code (Text):
    [12:14][[email protected] ~]# curl -I https://www.domain.org
    HTTP/1.1 301 Moved Permanently
    Date: Sun, 19 Aug 2018 04:14:42 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Location: https://domain.org/
    Server: nginx centminmod
    X-Powered-By: centminmod
    Strict-Transport-Security: max-age=31536000; includeSubdomains;
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    
     
  6. pdinh97qng

    pdinh97qng Member

    40
    5
    8
    Jan 24, 2016
    Ratings:
    +9
    Local Time:
    11:24 AM
  7. eva2000

    eva2000 Administrator Staff Member

    37,237
    8,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,524
    Local Time:
    5:24 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    that should be fixed by Xenforo - Too many redirect!

    make sure to restart both nginx and php-fpm services
    Code (Text):
    nprestart
    


    might need to clear/purge cloudflare cache
     
  8. pdinh97qng

    pdinh97qng Member

    40
    5
    8
    Jan 24, 2016
    Ratings:
    +9
    Local Time:
    11:24 AM
    Problem fix due to a missed config... Thank you eva
     
    • Like Like x 1
  9. pdinh97qng

    pdinh97qng Member

    40
    5
    8
    Jan 24, 2016
    Ratings:
    +9
    Local Time:
    11:24 AM
    @eva2000 I have another problem is my wordpress have 404 urls, and friendly url doesn't works with xenforo with above conf
     
  10. eva2000

    eva2000 Administrator Staff Member

    37,237
    8,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,524
    Local Time:
    5:24 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    missing try_files cache enabler rule in web root /
    Code (Text):
       location / {
           include /usr/local/nginx/conf/503include-only.conf;
           }
    

    should be
    Code (Text):
       location / {
           include /usr/local/nginx/conf/503include-only.conf;
          # for wp cache enabler plugin
          try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
           }
    
     
  11. pdinh97qng

    pdinh97qng Member

    40
    5
    8
    Jan 24, 2016
    Ratings:
    +9
    Local Time:
    11:24 AM
    WP Fixed, XenForo Friendly URLs doesn't work. Thank Eva
     
  12. eva2000

    eva2000 Administrator Staff Member

    37,237
    8,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,524
    Local Time:
    5:24 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    incorrect try_files for xenforo /community context

    change from
    Code (Text):
       location /community/ {
           try_files $uri $uri/ /index.php?$uri&$args;
           index index.php index.html;
           include /usr/local/nginx/conf/php.conf;
           }
    

    to missing /community/ in front of index.php
    Code (Text):
       location /community/ {
           try_files $uri $uri/ /community/index.php?$uri&$args;
           index index.php index.html;
           include /usr/local/nginx/conf/php.conf;
           }
    
     
..