too_many_redirects

Gregory Edigarov edigarov at qarea.com
Wed Jul 24 15:33:10 UTC 2019


Hello,

Having this setup:

nginx (on host) -> nginx (in docker-nginx [WP site resides here]) -> 
php-fpm(in docker-php)

got the error: too many redirects.

what could be the problem?

thanks a lot in advance.

config on host nginx:

server {
    listen 80;
    listen 443 ssl http2;
    server_name example.com;
    if ($scheme = http) {return 301 https://$server_name$request_uri;}

    access_log /var/log/access.log ;
    error_log /var/log/error.log ;

    location / {
        proxy_pass http://127.0.0.1:8181;
     proxy_redirect        off;
         proxy_set_header   Host $host;
         proxy_set_header   X-Real-IP $remote_addr;
         proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header   X-Forwarded-Host $server_name;
     }

}

config on dockerized nginx:

server {
    listen 80;

    server_name example.com;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    root /var/www;

    index index.php;

    gzip_vary on;
    gzip on;
    gzip_disable "msie6";
    gzip_comp_level 5;
# Compress the following MIME types.
     gzip_types
         application/atom+xml
         application/javascript
         application/json
         application/ld+json
         application/manifest+json
         application/rss+xml
         application/vnd.geo+json
         application/vnd.ms-fontobject
         application/x-font-ttf
         application/x-web-app-manifest+json
         application/xhtml+xml
         application/xml
         font/opentype
         image/bmp
         image/svg+xml
         image/x-icon
         text/cache-manifest
         text/css
         text/plain
         text/vcard
         text/vnd.rim.location.xloc
         text/vtt
         text/x-component
         text/x-cross-domain-policy;


    location ~* ^/.well-known/ {
       allow all;
    }

    location = /favicon.ico {
       log_not_found off;
       access_log off;
    }

    location = /robots.txt {
       #      allow all;
       log_not_found off;
       access_log off;
    }

    location / {
       try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
       fastcgi_pass php:9000; # aka docker-php:9000
       fastcgi_buffers 16 16k;
       fastcgi_read_timeout 300;
       fastcgi_buffer_size 32k;
       include fastcgi_params ;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_path_info;
       fastcgi_param QUERY_STRING $query_string;
       fastcgi_intercept_errors on;
    }

   location ~* \.(jpg|jpeg|png|css|js|ico|xml|txt)$ {
     access_log        off;
     log_not_found     off;
     expires           360d;
     add_header Cache-Control "public";
   }

   # Specify what happens what .ht files are requested
   location ~ /\.ht {
       deny all;
   }
}



More information about the nginx mailing list