Answer the question
In order to leave comments, you need to log in
"Rewrite or internal redirection cycle..." error. Why?
There is nginx, and under it is apache.
There are image files at `/uploads/images...`, requests to which are redirected to the script, and the latter decides whether to give the image or redirect the user to the login page.
.htaccess:
RewriteCond %{REQUEST_URI} ^/uploads.*
RewriteRule ^(.*)$ ./getpics.php [L]
location /uploads {
internal;
alias /files/uploads;
}
rewrite or internal redirection cycle while internally redirecting to "/uploads/images/00/0…" while reading response header from upstream, client: 66.87……, server: server.org, request: "GET /uploads/images/0… HTTP/1.1", upstream: "http://127.0.0.1:80/uploads/images/00…", host: "server.org"
server {
listen 123.45.67.89:80; ## listen for ipv4; this line is default and implied
root /var/www/sitename;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name sitename.com;
location /uploads/images/ {
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header RawURI $request_uri;
if ($check) {
proxy_pass http://127.0.0.1:80;
break;
}
root /var/www/sitename;
}
location / {
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header RawURI $request_uri;
proxy_pass http://127.0.0.1:80;
}
# http://stackoverflow.com/questions/16189758/serve-large-file-with-php-and-nginx-x-accel-redirect
location /uploads {
internal;
alias /files/uploads;
}
location ~ (\.mp3|avatar_\d+x\d+\.(jpe?|pn)g)$ {
}
}
Answer the question
In order to leave comments, you need to log in
In general, the problem was in the rule location /uploads/images/ {
that worked before location /uploads {
, redirected the request to Apache, which ran the script, which again redirected to Enginx, then to Apache, etc.
I solved it in this way: in the root of the site I created a symlink to / files with the name dwnld, in the nginx config I wrote
location /dwnld/ {
internal;
root /var/www/sitename;
}
http://sitename.com/uploads/file.jpg
as an option it could be something like this
uploads
/files/uploads
/files/uploads/files/uploads
/files/uploads/files/uploads/files/uploads
/files/uploads/files/uploads/files/uploads/files/uploads
/
> alias /files/uploads;
Do you have such a directory on the file system?
And in general there is no point in using alias, write root /path/on/file/system/files;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question