0

HomePage Redirect problem

Result
https://www.example.com
301 Moved Permanently
https://www.example.com/
301 Moved Permanently
https://www.example.com/
301 Moved Permanently
https://www.example.com/

>>> https://www.example.com

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 08 Mar 2020 17:12:27 GMT
Content-Type:   text/html; charset=UTF-8
Connection: close
Set-Cookie: PHPSESSID=nc8ae71cti111f4886i4n88c8g; path=/
X-Powered-By:   PHP/7.4.2
Expires:    Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control:  no-store, no-cache, must-revalidate
Pragma: no-cache
X-Redirect-By:  WordPress
Strict-Transport-Security:  max-age=63072000; includeSubDomains; preload
X-Frame-Options:    DENY
X-Content-Type-Options: nosniff
Location:   https://www.example.com/
X-Varnish:  275505
Age:    0
Via:    1.1 varnish (Varnish/6.0)
CF-Cache-Status:    DYNAMIC
Expect-CT:  max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Alt-Svc:    h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400
Server: cloudflare
CF-RAY: 570e2e5f387adfbb-FRA




>>> https://www.example.com/

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 08 Mar 2020 17:12:27 GMT
Content-Type:   text/html; charset=UTF-8
Connection: close
Set-Cookie: PHPSESSID=phieba6dvq78s19s6mnriqlkhi; path=/
X-Powered-By:   PHP/7.4.2
Expires:    Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control:  no-store, no-cache, must-revalidate
Pragma: no-cache
X-Redirect-By:  WordPress
Strict-Transport-Security:  max-age=63072000; includeSubDomains; preload
X-Frame-Options:    DENY
X-Content-Type-Options: nosniff
Location:   https://www.example.com/
X-Varnish:  275511
Age:    0
Via:    1.1 varnish (Varnish/6.0)
CF-Cache-Status:    DYNAMIC
Expect-CT:  max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Alt-Svc:    h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400
Server: cloudflare
CF-RAY: 570e2e625f301f15-FRA

Here is my nginx conf i use it for ssl since i have varnish on port 80 apache on port 8080 and nginx to lisen to 443 ssl.

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
            listen 443 ssl;
            server_name _;
index index.php index.html index.htm;
            ssl_certificate /etc/letsencrypt/live/www.sitename.com/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/www.sitename.com/privkey.pem;
            location / {
                proxy_pass http://127.0.0.1:80;
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Forwarded-Port 443;
                proxy_set_header Host $host;
            }
    }
}

My wordpress homepage in in infinite loop.

ERR_TOO_MANY_REDIRECTS

the rest of the website looks to work ok I have cloudflare as well as nameserver and caching. (the cookies all messed up also i think because i can't login to wp-admin)

I have checked using site http://www.redirect-checker.org/ and is telling that regular pages have like 4 redirects and homepage 19 (infinite loop)

Any idea how to fix ?

Jack Duldi
  • 19
  • 8
  • You don't have any redirect in your **nginx** configuration. One of your other servers is sending them. – Piotr P. Karwasz Mar 08 '20 at 15:42
  • where from varnish from httpd from where can it be i disable redirects on cloudflare – Jack Duldi Mar 08 '20 at 15:53
  • Use `curl` to find and identify a loop: start with `curl -i https://example.com/` and follow the `Location` headers. The remaining headers might give you a clue, which server generated the response. You can also crosscheck the access logs. – Piotr P. Karwasz Mar 08 '20 at 16:18
  • hi yes i try they all are the same redirecting same url over and over https://www.example.com - https://www.example.com – Jack Duldi Mar 08 '20 at 17:11
  • As you can see from the `HTTP` headers, the request passes through your entire daisy chain (Cloudflare -> nginx -> Varnish -> Apache -> PHP module) and hits Wordpress which issues the redirect. So you need to tell Wordpress whenever it is being accessed through `HTTPS`. Can you add the PHP related part of your Apache configuration? – Piotr P. Karwasz Mar 08 '20 at 19:49
  • i manage to do some crazyness and it worked... – Jack Duldi Mar 08 '20 at 20:00

0 Answers0