You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
Configured my rails application in controller with following:
reverse_proxy api_path, verify_ssl: true, headers: { 'X-API-Key' => mykey }, cookies: cookies do |config|
config.on_missing do |code, response|
puts "Body:#{response.body.to_s} Code:#{code} cookies:#{cookies}"
end
end
When I am calling API through Postman with same credentials it is showing results, but when I called same API through my rails application it is showing following:
<title>403 Forbidden</title>
403 Forbidden
cloudflare
Can you share a code snippet for setting a cookies for reverse-proxy?
The text was updated successfully, but these errors were encountered:
Hey, 3 years later... but did you manage to solve this CloudFlare 403 issue? If you can remember, I'd appreciate it if you could let me know how you did it! Cheers!
I fixed it by setting the host header to nil when calling reverse_proxy.
(Additional detail: the host header for the request to my reverse-proxy action was the URL of my main app server (in development, localhost:3000), and I guess that then causes problems when that header is forwarded along to the reverse proxy server. When I set the host header to nil, instead of forwarding the host header from the request to my main app server, the host header for the reverse proxy request gets set to the host of my reverse proxy server (in my example, my blog server), and in my case this causes Cloudflare to stop returning a 403.)
Here's the essence of how I did it (the key part being headers: { 'host' => nil }):
Hi
Configured my rails application in controller with following:
reverse_proxy api_path, verify_ssl: true, headers: { 'X-API-Key' => mykey }, cookies: cookies do |config|
config.on_missing do |code, response|
puts "Body:#{response.body.to_s} Code:#{code} cookies:#{cookies}"
end
end
When I am calling API through Postman with same credentials it is showing results, but when I called same API through my rails application it is showing following:
<title>403 Forbidden</title>
403 Forbidden
cloudflare
Can you share a code snippet for setting a cookies for reverse-proxy?
The text was updated successfully, but these errors were encountered: