我有一个 ruby on rails 应用程序,我想在一个路径上强制使用 SSL /accounts
,http
其余部分也一样。我当前的 Nginx 配置如下
server {
listen 80;
server_name example.com www.example.com;
rewrite ^/(.*) http://www.example.com/$1 permanent;
}
server {
listen 80;
server_name example.com www.example.com;
root /home/ubuntu/deploy/app_location/public;
location / {
rewrite ^ http://$server_name$request_uri? permanent;
}
location /accounts {
rewrite ^ https://$server_name$request_uri? permanent;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
#rewrite (.*) https://$server_name$1 permanent;
}
server {
listen 443;
ssl on;
server_name example.com www.example.com;
...ssl stuff
resolver 8.8.8.8;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
root /home/ubuntu/deploy/app_location/public;
location / {
rewrite ^ http://$server_name$request_uri? permanent;
}
location /accounts {
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
#proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
Nginx 不断重定向并且没有进入应用程序的根目录,我在这里做错了什么?