1

I've been reading another similar issues and changing some things in my Nginx configuration, but no one worked :/

When I'm trying to access to a specific page at my site, it leads me to a "redirect loop". I'm using SSL, PHP and Yii as a framework, and page isn't for login or similar.

My Nginx config is:

server {
        listen 80;
        root /usr/share/nginx/www/domain;
        index index.php index.html index.htm;
        server_name www.domain.com;
        return 301 https://$host$request_uri;
        access_log on;
        error_log  /var/log/nginx-error_log crit;
location ~* .(gif|jpg|jpeg|png|ico|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|mid|js|css|html|htm|wml)$ {
        root /usr/share/nginx/www/domain;
        expires 365d;
        }
location / {
        try_files $uri $uri/ /index.html;
        client_max_body_size    10m;
        client_body_buffer_size 128k;
        proxy_send_timeout   90;
        proxy_read_timeout   90;
        proxy_buffer_size    128k;
        proxy_buffers     4 256k;
        proxy_busy_buffers_size 256k;
        proxy_temp_file_write_size 256k;
        proxy_connect_timeout 30s;
        proxy_redirect  http://www.domain.com:8080   http://www.domain.com;
        proxy_pass   http://127.0.0.1:8080/;
        #Redirect loop problem, next line:
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host   $host;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www/domain;
        }
        location = /favicon.ico {
        log_not_found off;
        }
}

for non-SSL and:

# HTTPS server
server {
        listen 443 default ssl;
        ssl_certificate /etc/ssl/www.crt;
        ssl_certificate_key /etc/ssl/www.key;
        root /usr/share/nginx/www/domain;
        index index.php index.html index.htm;
        server_name www.domain.com;
        access_log on;
        error_log  /var/log/nginx-error_log crit;
location ~* .(gif|jpg|jpeg|png|ico|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|mid|js|css|html|htm|wml)$ {
        root /usr/share/nginx/www/domain;
        expires 365d;
        }
location / {
        try_files $uri $uri/ /index.html;
        client_max_body_size    10m;
        client_body_buffer_size 128k;
        proxy_send_timeout   90;
        proxy_read_timeout   90;
        proxy_buffer_size    128k;
        proxy_buffers     4 256k;
        proxy_busy_buffers_size 256k;
        proxy_temp_file_write_size 256k;
        proxy_connect_timeout 30s;
        proxy_redirect  http://www.domain.com:8080   http://www.domain.com;
        proxy_pass   http://127.0.0.1:8080/;
        #Redirect loop problem, next line:
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host   $host;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www/domain;
        }
        location = /favicon.ico {
        log_not_found off;
        }
}

for SSL. You'll see that I was trying different answers from here, without success.

Can anyone help me, please?

Best.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.