# Nginx proxy to apache ERR\_TOO\_MANY\_REDIRECTS

**URL:** <https://www.ruby-forum.com/t/nginx-proxy-to-apache-err-too-many-redirects/235257>\
**Category:** NGINX\
**Created:** [June 10, 2013, 1:05pm UTC](https://www.ruby-forum.com/t/nginx-proxy-to-apache-err-too-many-redirects/235257 "2013-06-10T13:05:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [June 10, 2013, 1:05pm UTC](https://www.ruby-forum.com/t/nginx-proxy-to-apache-err-too-many-redirects/235257/1 "2013-06-10T13:05:16Z")

</div>

i have the following setup which uses nginx as proxy to an apache  
instance  
running prestashop, this works ok, but i get from time to time Error 310  
ERR\_TOO\_MANY\_REDIRECTS and i can’t figure out where this is coming from  
and  
i also get these error in the apache log:

```
[Sun Jun 09 18:57:01 2013] [error] [client xx.xx.xx.xx] client sent

```

HTTP/1.1 request without hostname (see RFC2616 section 14.23):  
/w00tw00t.at.ISC.SANS.DFind:)  
[Sun Jun 09 19:21:29 2013] [error] [client xx.xx.xx.xx] client sent  
HTTP/1.1 request without hostname (see RFC2616 section 14.23):  
/w00tw00t.at.ISC.SANS.DFind:)

here is my setup:

```
# nginx -V
nginx version: nginx/1.4.1
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I

```

/usr/local/include’ --with-ld-opt=‘-L /usr/local/lib’  
–conf-path=/usr/local/etc/nginx/nginx.conf  
–sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid  
–error-log-path=/var/log/nginx-error.log --user=www --group=www  
–with-ipv6  
–with-google\_perftools\_module  
–http-client-body-temp-path=/var/tmp/nginx/client\_body\_temp  
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi\_temp  
–http-proxy-temp-path=/var/tmp/nginx/proxy\_temp  
–http-scgi-temp-path=/var/tmp/nginx/scgi\_temp  
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi\_temp  
–http-log-path=/var/log/nginx-access.log --with-http\_geoip\_module  
–with-http\_gzip\_static\_module --with-http\_realip\_module  
–with-http\_stub\_status\_module  
–add-module=/usr/ports/www/nginx/work/simpl-ngx\_devel\_kit-48bc5dd  
–add-module=/usr/ports/www/nginx/work/chaoslawful-lua-nginx-module-3915187  
–with-pcre  
–add-module=/usr/ports/www/nginx/work/yaoweibin-nginx\_tcp\_proxy\_module-b83e5a6  
–with-http\_ssl\_module

```
# httpd -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (shared)
 authn_dbm_module (shared)
 authn_anon_module (shared)
 authn_default_module (shared)
 authn_alias_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_dbm_module (shared)
 authz_owner_module (shared)
 authz_default_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 file_cache_module (shared)
 cache_module (shared)
 disk_cache_module (shared)
 dumpio_module (shared)
 reqtimeout_module (shared)
 include_module (shared)
 filter_module (shared)
 charset_lite_module (shared)
 deflate_module (shared)
 log_config_module (shared)
 logio_module (shared)
 env_module (shared)
 mime_magic_module (shared)
 cern_meta_module (shared)
 expires_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 unique_id_module (shared)
 setenvif_module (shared)
 version_module (shared)
 ssl_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 asis_module (shared)
 info_module (shared)
 cgi_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 imagemap_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 php5_module (shared)
 rpaf_module (shared)

```

then in my /usr/local/etc/nginx/nginx.conf i have:

```
#user nobody;
worker_processes 4; #x2 per CPU

error_log /var/www/logs/nginx_error.log notice;

#pid logs/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
sendfile on;

keepalive_timeout 5;

gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json 

```

application/javascript  
application/x-javascript text/javascript text/xml application/xml  
application/rss+xml application/atom+xml application/rdf+xml;

```
gzip_buffers 16 8k;
server {
    listen 178.xxx.xxx.xxx:80;
    server_name test.domain.tld;
    location ~ ^.+\.(jpg|jpeg|gif|png|ico|css|js)$ {
            root /www/domain.tld/http;
            expires max;
            access_log off;
            include custom/prestashop_params;
    }
    include custom/expires_params;
    location / {
            include custom/proxy_params;
            proxy_pass http://127.0.0.1:81;
    }
}

```

the `custom/prestashop_params` are as follows:

```
# cat custom/prestashop_params
rewrite "^/([a-z]{2})/js/(.+)$" /js/$2 last;
rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$

```

/img/p/$1/$1$2$3.jpg last;  
rewrite ^/([0-9])([0-9])(-[\_a-zA-Z0-9-]_)?(-[0-9]+)?/.+.jpg$  
/img/p/$1/$2/$1$2$3$4.jpg last;  
rewrite  
^/([0-9])([0-9])([0-9])(-[\_a-zA-Z0-9-]_)?(-[0-9]+)?/.+.jpg$  
/img/p/$1/$2/$3/$1$2$3$4$5.jpg last;  
rewrite  
^/([0-9])([0-9])([0-9])([0-9])(-[\_a-zA-Z0-9-]_)?(-[0-9]+)?/.+.jpg$  
/img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;  
rewrite  
^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[\_a-zA-Z0-9-]_)?(-[0-9]+)?/.+.jpg$  
/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;  
rewrite  
^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[\_a-zA-Z0-9-]_)?(-[0-9]+)?/.+.jpg$  
/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;  
rewrite  
^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[\_a-zA-Z0-9-]_)?(-[0-9]+)?/.+.jpg$  
/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;  
rewrite  
^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[\_a-zA-Z0-9-]_)?(-[0-9]+)?/.+.jpg$  
/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;  
rewrite ^/c/([0-9]+)(-[.__a-zA-Z0-9-]\*)(-[0-9]+)?/.+.jpg$  
/img/c/$1$2$3.jpg last;  
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;  
rewrite ^/images\_ie/?([^/]+).(jpe?g|png|gif)$  
/js/jquery/plugins/fancybox/images/$1.$2 last;

and `custom/proxy_params`:

```
# cat custom/proxy_params
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Range "";
proxy_set_header Request-Range "";
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 16 128k;
proxy_busy_buffers_size 128k;
proxy_buffer_size 128k;
proxy_cache nginx-cache;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
proxy_redirect off;

```

http.conf is setup to listen to port 81 and the vhost is:

```
<VirtualHost *:81>
    ServerAdmin removed_email_address@domain.invalid
    DocumentRoot /www/domain.tld/http/
    ServerName domain.tld
    <Directory "/www/domain.tld/http">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /www/domain.tld/logs/error_log
    CustomLog /www/domain.tld/logs/access_log common
</VirtualHost>

```

i also have IPFW setup on my server and have opened both port 80 and 81  
but  
not sure this has anything to do with it.

is there a way to trace this, so that i can understand it better?  
perhaps  
the issue is the .htaccess in the /www/domain.tld/http root directory  
that  
is causing this!

and can this setup be made simpler, as i will have several prestashops  
instances running from this server with individual SSL certificates?

any advice much appreciated.

Posted at Nginx Forum:

> **[nginx proxy to apache ERR\_TOO\_MANY\_REDIRECTS](https://forum.nginx.org/read.php?2,239993,239993#msg-239993)**
>
> i have the following setup which uses nginx as proxy to an apache instance running prestashop, this works ok, but i get from time to time Error 310 ERR\_TOO\_MANY\_REDIRECTS and i can't figure out where this is coming from and i also get these error in...

---

<div class="post-metadata">

**Author:** ![khine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c67d28/32.png) [@khine](https://www.ruby-forum.com/u/khine)\
**Post date:** [June 10, 2013, 1:09pm UTC](https://www.ruby-forum.com/t/nginx-proxy-to-apache-err-too-many-redirects/235257/2 "2013-06-10T13:09:57Z")

</div>

On 10 June 2013 12:04, khine [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i also get these error in the apache log:
> 
> ```
> [Sun Jun 09 18:57:01 2013] [error] [client xx.xx.xx.xx] client sent
> 
> ```
> 
> HTTP/1.1 request without hostname (see RFC2616 section 14.23):  
> /w00tw00t.at.ISC.SANS.DFind:)  
> [Sun Jun 09 19:21:29 2013] [error] [client xx.xx.xx.xx] client sent  
> HTTP/1.1 request without hostname (see RFC2616 section 14.23):  
> /w00tw00t.at.ISC.SANS.DFind:)

> **[LMGTFY](https://lmgtfy.com/?q=w00tw00t)**
>
> Let Me Google That For You (LMGTFY): for all those people who find it more convenient to bother you with their question rather than search it for themselves.

Jonathan
