Question
Error 400
I just finished going through the following tutorial, but keep getting an error when trying to access my rails app:
https://www.digitalocean.com/community/articles/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5
When I access my droplet's URL I get the following error:
400 Bad Request: Request Header Or Cookie Too Large
The nginx error log shows the following:
client sent too long header line: "X-Forwarded-For: [my computer's ip], [my droplet's ip multiple times]
It looks like something is causing an infinite loop with the droplet IP, but I can't find anywhere in the configuration that would cause that.
commenting the 'X-Forwarded-For' line in default.conf gets rid of the 400 error, but leads to a 502 Bad Gateway error.
Here is what I have in my default.conf (website info redacted):
upstream app {
# Path to Unicorn SOCK file, as defined previously
server unix:/tmp/unicorn..sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
# Application root, as defined previously
root /usr/share/nginx/html/;
try_files $uri/index.html $uri @;
location @ {
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass ;
}
large_client_header_buffers 4 32k;
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
I am unfortunately out of ideas so any help would be appreciated!
Thanks in advance!
Add a comment
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×