ERR_TOO_MANY_REDIRECTS Nginx ERR_TOO_MANY_REDIRECTS Nginx nginx nginx

ERR_TOO_MANY_REDIRECTS Nginx


Recently I configured my Odoo app to forward all requests via Nginx.You need to add something like this to your Nginx config:

upstream tomcat {    server 127.0.0.1:8080;}server {        listen   80;        server_name www.mydomain.com;        location / {        proxy_pass  http://tomcat;        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;        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-Proto https;    }        proxy_read_timeout 600s;        client_max_body_size 200m;        }}

If this doesn't work, for reference, you may want to check this article: https://www.rosehosting.com/blog/install-odoo-on-a-debian-8-vps-with-nginx-as-a-reverse-proxy/

I hope you'll find this useful.


It is common to set the proxy_redirect directive in the same way as the proxy_pass directive. see for example configure-nginx-with-proxy-pass.

location ~ ^/stash {    proxy_pass http://IP:7990;    proxy_redirect   http://IP:7990/  /stash;}

but I got the ERR_TOO_MANY_REDIRECTS error with this configuration... so i changed it for "proxy_redirect off;" as suggested here, and it solved my problem!

here is the configuration for my gitlab server:

server {    listen 80;    server_name reverseproxy.mydomain.org;    location /gitlab/ {            proxy_set_header X-Real-IP       $remote_addr;            proxy_set_header Host-Real-IP    $http_host;            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            proxy_pass       http://172.xx.xx.xxx:10080;            #proxy_redirect http://172.xx.xx.xxx:10080/ /gitlab/;                       proxy_redirect   off;               }}

NB: i also needed to remove the directive "proxy_set_header Host $host;" for my gitlab server, powered by docker-gitlab.