我一直在阅读另一个类似的问题并更改我的 Nginx 配置中的一些内容,但没有人工作:/
当我尝试访问网站上的特定页面时,它会导致我进入“重定向循环”。我使用 SSL、PHP 和 Yii 作为框架,页面不是用于登录或类似的。
我的 Nginx 配置是:
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;
}
}
对于非 SSL 以及:
# 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;
}
}
对于 SSL。你会发现我在这里尝试了不同的答案,但没有成功。
有人可以帮我吗?
最好的。