Eu tenho um aplicativo ruby on rails que quero forçar o ssl em um caminho /accounts
e http
para o restante do aplicativo. Minha configuração atual do Nginx é a seguinte
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;
}
O Nginx continua redirecionando e não indo para a raiz do aplicativo, o que estou fazendo de errado aqui?
Tags nginx ruby-on-rails