CentOS7
rails6
nginx
unicorn
上記の環境でアプリを作っています。
TwitterのAPIを使用してログイン機能を作ったのですが、SSL化した本番環境でうまく動きません。
Twitterでログインをすると、
「auth/failure?message=invalid_credentials&strategy=twitter」
と返ってきます。しかし、認証はうまくできているのです。
正直自分でもどういう状況かよく分からないのですが、
「auth/failure?message=invalid_credentials&strategy=twitter」と「/auth/twitter/callback」が
同時に返ってきてる(?)という状況です。
ssl化をする前には正常に動いていたので、nginxに問題があるのかと思うのですが、分からないです。
以下はnginxの設定です。
nginx
1user user; 2worker_processes auto; 3error_log /var/log/nginx/error.log; 4pid /run/nginx.pid; 5 6# Load dynamic modules. See /usr/share/nginx/README.dynamic. 7include /usr/share/nginx/modules/*.conf; 8 9events { 10 worker_connections 1024; 11} 12 13http { 14 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 15 '$status $body_bytes_sent "$http_referer" ' 16 '"$http_user_agent" "$http_x_forwarded_for"'; 17 18 access_log /var/log/nginx/access.log main; 19 20 sendfile on; 21 tcp_nopush on; 22 tcp_nodelay on; 23 keepalive_timeout 65; 24 types_hash_max_size 2048; 25 26 include /etc/nginx/mime.types; 27 default_type application/octet-stream; 28 29 include /etc/nginx/conf.d/*.conf; 30 31 upstream unicorn { 32 server unix:/home/user/app/tmp/unicorn.sock; 33 } 34 35 server { 36 listen 80; 37 server_name app.com; 38 return 301 https://$host$request_uri; 39 } 40 41 server { 42 listen 443 ssl; 43 server_name app.com; 44 # root /usr/share/nginx/html; 45 root /home/user/app/public; 46 client_max_body_size 70m; 47 48 ssl on; 49 ssl_certificate "/etc/nginx/ssl.crt/server.crt"; 50 ssl_certificate_key "/etc/nginx/ssl.key/server.key"; 51 ssl_session_cache shared:SSL:1m; 52 ssl_session_timeout 10m; 53 ssl_ciphers HIGH:!aNULL:!MD5; 54 ssl_prefer_server_ciphers on; 55 56 try_files $uri/index.html $uri @unicorn; 57 58 # Load configuration files for the default server block. 59 include /etc/nginx/default.d/*.conf; 60 61 location ~ ^/assets/ { 62 root /home/user/app/public; 63 } 64 65 location @unicorn { 66 root /home/user/app/public; 67 68 proxy_set_header Host $http_host; 69 proxy_set_header X-Real-IP $remote_addr; 70 proxy_set_header X-Forwarded-Proto https; 71 proxy_set_header X-Forwarded-Host $host; 72 proxy_set_header X-Forwarded-Server $host; 73 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 74 proxy_redirect http:// https://; 75 proxy_pass http://unicorn; 76 } 77 78 error_page 404 500 502 503 504 /error.html; 79 location = /error.html { 80 root /usr/share/nginx/html; 81 } 82 } 83}
対処法をご存じの方はご教授願います。
不足している情報等あれば教えてください。
あなたの回答
tips
プレビュー