NGINX - InvalidAuthenticityToken error fix

When using NGINX with Devise, Ruby On Rails, there one can face with error "InvalidAuthenticityToken in Rails 5 behind Nginx using SSL" .

In order to fix this problem we should add headers in nginx configuration file:



tt@tt:/etc/nginx/sites-available$ cat default 

upstream rails {

server localhost:9000;

}


server {

listen 80 default;

server_name www.starlab.com;


location /{

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_set_header Host $http_host;

        proxy_redirect off;

proxy_pass http://rails;

}

}


Comments