D
D
d88a2021-12-08 09:30:30
htaccess
d88a, 2021-12-08 09:30:30

How to fix ERR_TOO_MANY_REDIRECTS error on Nginx + Apache?

Hello. How to fix ERR_TOO_MANY_REDIRECTS error?
Occurs when a redirect code from https to http of one page is added to .htaccess

RewriteCond %{REQUEST_URI} ^/dir1/(.*)$ 
RewriteRule ^(.*)$ http://сайт/dir1/%1 [R=301,L]

There is no error when adding RewriteCond %{HTTPS} on, but it works once without a cache.

Nginx + Apache is used, this problem may be due to the fact that the connection goes to Nginx, and Apache is already behind it. And need to edit Nginx?
###
load_module "modules/ngx_http_htpasswd_module.so";
load_module "modules/ngx_stream_module.so";
worker_processes  2;
error_log  /dev/null;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    map $http_x_forwarded_proto $thescheme { default $scheme; https https; }
    set_real_ip_from 10.1.0.0/16;
    set_real_ip_from 10.3.0.0/16;
    set_real_ip_from 10.12.0.0/16;
    set_real_ip_from 10.52.0.0/14;
    set_real_ip_from 31.177.93.0/24;
    set_real_ip_from 195.208.0.0/23;
    real_ip_header X-Real-IP;

    ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers     GOST2012-GOST8912-GOST8912:EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:EDH+aRSA:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;

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

    access_log      off;

    sendfile        on;
    keepalive_timeout  65;
    include /etc/nginx/sites.conf;
}

stream {
    server {
        listen 127.0.0.1:3306;
        proxy_pass unix:/var/run/mysqld/mysqld.sock;
    }

}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question