Welcome! Log In Create A New Profile

Advanced

nginx proxy to apache ERR_TOO_MANY_REDIRECTS

June 10, 2013 07:04AM
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 admin@domain.tld
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.
SubjectAuthorPosted

nginx proxy to apache ERR_TOO_MANY_REDIRECTS

khineJune 10, 2013 07:04AM

Re: nginx proxy to apache ERR_TOO_MANY_REDIRECTS

Jonathan MatthewsJune 10, 2013 07:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 61
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 229 on August 01, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready