我有我的yii 1.1.21网站在iis 8.5,但我需要迁移到nginx,我在nginx新手,所以我尝试使用这个指南:
(https://www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config)(英文)
在主页上一切正常,但当我在我的网站导航时,几乎所有的时间都有错误“ERR_TOO_MANY_REDIRECTS”。我尝试了许多解决方案,但都不起作用。
我发布了我的默认文件下面的更多信息:
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/certs/key.crt; # path to your cacert.pem
ssl_certificate_key /etc/ssl/private/<sermername>.key; # path to your privkey.pem
server_name <server name>;
server_tokens off;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-R$
root /var/www/html;
index index.php
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 1200s;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'";
add_header Referrer-Policy no-referrer;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options SAMEORIGIN always;
add_header X-XSS-Protection "1; mode=block" always;
# add_header Content-Security-Policy-Report-Only
access_log /var/log/nginx/default.access.log combined;
error_log /var/log/nginx/default.error.log warn;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
# fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
1条答案
按热度按时间inn6fuwd1#
经过2天打破了我的头,我找到了解决方案,我的网站工作负载平衡和yii会话没有工作,以及多服务器默认.我的解决方案是启用CDbHttpSession存储会话在数据库中.更多参考:Load balancing with Yii sessionsYii session do not work in multi server显示器