Handle Long URL Redirects NGINX

Over the past couple of weeks, I have been working on a URL Shortener Service. When testing the ability to shorten really long urls (over 3500+ characters) I ran into an issue I had never seen before. When trying to redirect to the long url, NGINX would return a 502 error (upstream sent too big header while reading response header from upstream). After some research, I discovered the long url is sent in the header of the response. To fix this issue, I had to change the fastcgi_buffers and fastcgi_buffer_size setting in the location section of NGNIX.

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;


 

If you are looking for a simple url shortener api service, you should check out t.ly.

NGNIX Reference

Stackoverflow Reference


Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LYWeather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.  

Leave a Reply

Your email address will not be published. Required fields are marked *