POST请求在使用http而不是https时被转换为GET请求

添加SSL后,我注意到一个奇怪的行为:在地址中使用HTTP协议的所有API POST请求正在变成GET请求,这就是为什么我得到ActionController::RoutingError (No route matches [GET] "/api/v2/users")错误。

我的nginx.conf:

 upstream unicorn_staging.xxxxx.com { server unix:/srv/www/xxxxx/shared/sockets/unicorn.sock fail_timeout=0; } server { listen 80; server_name staging.xxxxx.com xxxxx dublin; access_log /var/log/nginx/staging.xxxxx.com.access.log; keepalive_timeout 5; root /srv/www/xxxxx/current/public/; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; # If you don't find the filename in the static files # Then request it from the unicorn server if (!-f $request_filename) { proxy_pass http://unicorn_staging.xxxxx.com; break; } } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } error_page 500 502 503 504 /500.html; location = /500.html { root /srv/www/xxxxx/current/public/; } } server { listen 443; server_name staging.xxxxx.com xxxxx dublin; access_log /var/log/nginx/staging.xxxxx.com-ssl.access.log; ssl on; ssl_certificate /etc/nginx/ssl/staging.xxxxx.com.crt; ssl_certificate_key /etc/nginx/ssl/staging.xxxxx.com.key; keepalive_timeout 5; root /srv/www/xxxxx/current/public/; location / { 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; # If you don't find the filename in the static files # Then request it from the unicorn server if (!-f $request_filename) { proxy_pass http://unicorn_staging.xxxxx.com; break; } } error_page 500 502 503 504 /500.html; location = /500.html { root /srv/www/xxxxx/current/public/; } } 

我正在使用Ruby on Rails,Nginx和独angular兽。 我已经在rails中将force_ssl设置为true,所以它会自动将所有请求redirect到https。 访问日志时使用https:

[01/Apr/2016:08:58:28 +0000] "GET /api/v2/users HTTP/1.1" 404 15384 "-" "XxxxStaging/28 CFNetwork/758.2.8 Darwin/15.0.0"

访问日志时使用http:

[01/Apr/2016:09:00:08 +0000] "POST /api/v2/users HTTP/1.1" 201 1620 "-" "curl/7.43.0"