What is the maximum length of an apache url?

What is the maximum url length in apache? Where is it documented and configured?

I am implementing an openid authentication provider and want to know the limitations that I am against. I know about the 2048 byte limit in Internet Explorer. This can be handled specifically using user agent discovery. Other browsers have much higher URL limits.

So, I'm interested in limiting the Apache server when coding an application.

+50
url apache
Aug 17 '09 at 18:25
source share
5 answers

The default limit for the length of the query string is 8190 bytes (see LimitRequestLine ). And if we subtract three bytes for the request method (i.e. GET ), eight bytes for version information (i.e. HTTP/1.0 / HTTP/1.1 ) and two bytes for the separation space, we get 8177 bytes for the URI path plus request.

+59
Aug 17 '09 at 18:31
source share
  • Internet Explorer: 2083 characters with no more than 2048 characters in the part of the URL path.
  • Firefox: 65,536 characters appeared, but longer URLs still work even up to 100,000
  • Safari:> 80,000 characters
  • Opera:> 190,000 characters
  • IIS: 16,384 characters but configurable
  • Apache: 4000 characters

From: http://www.danrigsby.com/blog/index.php/2008/06/17/rest-and-max-url-size/

+15
Aug 17 '09 at 18:30
source share

The official length according to official Apache docs is 8 192, but many people have encountered a problem at ~ 4000.

MS Internet Explorer is usually a limiting factor, as it limits the maximum URL size to 2.048.

+6
Aug 17 '09 at 18:29
source share

Here's a bash script to check the maximum limit of a remote server (uses curl and perl).

You just need some kind of url that can be expanded with "x" and always return 200 (or adapt it to your needs). At some point, it will break, and the script will display the maximum length.

Here is the code:

 url='http://someurl/someendpoint?var1=blah&token=' ok=0 times=1 while :; do length=$((times+${#url})) echo trying with $length token=$(perl -le 'print "x"x'$times) result=$(curl -sLw '%{http_code}' -o /dev/null "${url}${token}") if [[ $result == 200 ]]; then if [[ $ok == $times ]]; then echo "max length is $length" break fi ok=$times times=$((times+1024)) else times=$(((times+ok)/2)) fi done 
+3
Apr 23 '14 at 11:31
source share

The default allowed URI size is 8177 characters in a GET request. Simple python code for such testing.

 #!/usr/bin/env python2 import sys import socket if __name__ == "__main__": string = sys.argv[1] buf_get = "x" * int(string) buf_size = 1024 request = "HEAD %s HTTP/1.1\nHost:localhost\n\n" % buf_get print "===>", request sock_http = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock_http.connect(("localhost", 80)) sock_http.send(request) while True: print "==>", sock_http.recv(buf_size) if not sock_http.recv(buf_size): break sock_http.close() 

For 8178 characters you will receive the following message: HTTP / 1.1 414 Request-URI Too Large

+2
Sep 14 '11 at 11:57
source share



All Articles