我有一个带狂欢的Rails应用程序。该应用程序在www上提供。我正在使用passenger和nginx,将letencrypt作为ssl。
这是nginx的配置:
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 404; # managed by Certbot
location @passenger {
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
passenger_enabled on;
rails_env production;
root /path_to_app
}
Spree管理员可以在https中正常工作,但是由于我收到太多重定向错误,因此前端无法正常工作。
我在前端注意到的另一件事是,重定向到https(出现重定向错误)后,如果我重新加载页面,它将返回到http(仍然出现重定向错误)。
除了我在production.rb上设置的以外:
config.force_ssl = true
和inizialiters / spree,rb:
config.allow_ssl_in_production = true
我该如何解决?