Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx url limit 502 gateway

I have a question but I accept other suggestions that bypass this feature.

Basically I'm sending big lines of text ~3000 characters to my server in a get request and the server sends it to google translate as params in a url.

The problem: Nginx throws me a 502 bad gateway error when the url is > 1900 characters.

How can I increase the limit of my nginx url?

Alternative Solution: Sending a post request with the 3000 characters in a JSON as a string?

like image 863
mateo_io Avatar asked Nov 04 '16 15:11

mateo_io


People also ask

Does 502 Bad gateway mean blocked?

Does 502 bad gateway mean blocked? If your computer screen displays an error message stating “502 bad gateway”, it means the server which is acting as a proxy or gateway is not getting adequate response from another server. But this is a generic error, you won't be able to find out the root cause.


2 Answers

To answer your question, there is a setting you can change in the nginx.conf file containing your server's configuration.

Set the following setting to something that seems fitting to your situation:

large_client_header_buffers 4 16k;

Find the documentation for it here.

I would suggest to use a POST request in case your ~3000 character requests get bigger and your nginx configuration reaches it limit.

like image 191
Tom Nijs Avatar answered Nov 05 '22 14:11

Tom Nijs


The important thing to notice here is that a 502 error is a problem downstream. You're probably using nginx as a reverse proxy, and it's the service that you're forwarding to which is failing.

In my case, I was using nginx to forward traffic to a docker instance which was using uwsgi. So I needed to up the 'buffer-size' parameter in my uwsgi configuration. But your specific solution will depend on the service that you're forwarding to.

like image 20
Aaron Avatar answered Nov 05 '22 13:11

Aaron