禁止 + 在生产服务器上使用 sidekiq/devise/activeadmin 注销 nginx/haproxy/thin
Forbidden + sign out using sidekiq/devise/activeadmin on production server with nginx/haproxy/thin
我们在带有 nginx、haproxy、thin 的生产服务器上使用 sidekiq gem。我们还为经过身份验证的管理员用户(activeadmin)使用 sidekiq UI:
authenticate :admin_user do
mount Sidekiq::Web => '/sidekiq'
end
验证后我们尝试打开/sidekiq。我们没有看到 sidekiq ui,而是只收到 "forbidden"。此外,我们失去了设计 session。因此,如果我们尝试打开 /admin,activeadmin 会再次请求ui重新验证。
我们只在生产服务器上遇到这个问题,在开发服务器上它工作正常。
我们使用:
nginx(https)
代理(http)
薄 (http)
sidekiq 4.1.1
设计 3.5.6
activeadmin 1.0.0.pre2
西纳特拉 1.4.7
您需要将适当的 headers 转发到您的应用程序,否则 rack-protection 将阻止请求。
在Nginx服务器配置中你需要:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
然后在 HAProxy 中您需要将 IP 转发给您的应用
option forwardfor header X-Client
我曾经 option forwardfor header X-Real-IP
在应用程序中传输 IP,但这不适用于 rack-protection。
我们在带有 nginx、haproxy、thin 的生产服务器上使用 sidekiq gem。我们还为经过身份验证的管理员用户(activeadmin)使用 sidekiq UI:
authenticate :admin_user do
mount Sidekiq::Web => '/sidekiq'
end
验证后我们尝试打开/sidekiq。我们没有看到 sidekiq ui,而是只收到 "forbidden"。此外,我们失去了设计 session。因此,如果我们尝试打开 /admin,activeadmin 会再次请求ui重新验证。
我们只在生产服务器上遇到这个问题,在开发服务器上它工作正常。
我们使用: nginx(https) 代理(http) 薄 (http) sidekiq 4.1.1 设计 3.5.6 activeadmin 1.0.0.pre2 西纳特拉 1.4.7
您需要将适当的 headers 转发到您的应用程序,否则 rack-protection 将阻止请求。
在Nginx服务器配置中你需要:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
然后在 HAProxy 中您需要将 IP 转发给您的应用
option forwardfor header X-Client
我曾经 option forwardfor header X-Real-IP
在应用程序中传输 IP,但这不适用于 rack-protection。