Reputation: 574
Although I am by no means an expert on Ubuntu, I have had two servers running for a couple of years with no problems.
Last night, when attempting to access a local website on one of them I got the error:
**Bad Request**
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.
After several hours of frustration and no success, I rebuilt the server. While Ubuntu was installing I went to the other server and got the exact same error. The first server has now been rebuilt and it displays the same error.
I have shut down every computer on the network. Powered down the router and started over.
In addition to the two servers, the network consists of three windows machines and a Ubuntu desktop.
I have tried isolating the machines from the Internet, I have tried both wired and wireless clients.
Going to localhost on the servers displays the Ubuntu Apache Default page.
The only thing that happened about the time the problem started was the Windows decided to shutdown this machine for an update. I don't see how this could have caused a problem but I have isolated this machine from the network and the problem exists.
I cleared cookies, used five different browsers, and they all report the same error. I'm about out of ideas, and looking for any suggestions.
Upvotes: 31
Views: 67688
Reputation: 471
This is due to the update RFC 3986, which claims that underscores are unsafe in virtual host servernames and other elements. In my case, I could not change the URL name, so I just allowed this underscores by enabling these unsafe urls. To do that, just add HttpProtocolOptions unsafe
to the httpd.conf file.
https://httpd.apache.org/docs/2.4/mod/core.html#httpprotocoloptions
Upvotes: 29
Reputation: 387
I am using Microsoft identity. In my case, user claims in table claims in db was very high. The user's problem was solved when I deleted the user's claims in the table and cleared the cookie in user browser.
Upvotes: 0
Reputation: 485
For me, the issue what that the upstream backend definition of the Nginx server contains an underscore. It was hard for me to detect because centos1
and centos
were remote hosts running Nginx servers whereas the last server is localhost
httpd server. The two remote servers were load-balancing fine, but not the last which makes it difficult to figure out that it was the _
underscore that is the issue.
Before
location / {
proxy_pass http://server_group;
}
upstream server_group {
server centos1;
server centos2;
server localhost:8085;
}
After
location / {
proxy_pass http://servergroup;
}
upstream servergroup {
server centos1;
server centos2;
server localhost:8085;
}
Upvotes: 0
Reputation: 4113
In Docker Compose, if you use the networking that allows you to use container names as urls/hosts to communicate back and forth, you need to make sure you don't use underscores in the name (per Nero's answer).
This took me forever to debug, so I'm including the initial error text below (again) so that hopefully Google serves this question a little higher to the next person trying to fix php curl on a docker network.
400 Bad Request Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.
Upvotes: 2
Reputation: 19505
I had to remove the underscore (_
) from the ServerName
directive, as well as the hostname in /etc/hosts
.
However, the underscore in DocumentRoot
is just fine.
Thus, the relevant line in /etc/hosts
looks like this:
127.0.0.1 mycoolsite.localhost
And the relevant block in /etc/apache2/extra/httpd-vhosts.conf
looks like this:
<VirtualHost *:80>
DocumentRoot "/Users/satoshi/Sites/my_cool_site"
ServerName mycoolsite.localhost
ErrorLog "/private/var/log/apache2/my_cool_site.localhost-error_log"
CustomLog "/private/var/log/apache2/my_cool_site.localhost-access_log" common
</VirtualHost>
Don't forget to run apachectl restart
after making your changes.
Upvotes: 3
Reputation: 1719
This error haunted me for days, untill I finally got it.
In my case, I was making a CURL to an URL that has an empty space at the end. Can you believe it? Removing the space was enough to work fine.
Upvotes: 1
Reputation: 101
For newer httpd versions do not support Hyphens in the URL in that case you have to add HttpProtocolOptions unsafe to the httpd.conf file, it works fine after that.
Upvotes: 10
Reputation: 1575
In my case, it's actually the underscore _
in DocumentRoot that causes problem and hours of debugging. All work fine once I remove it from my DocumentRoot path.
Upvotes: 93
Reputation: 574
Okay, I'm 99.99% sure I have found the problem with the help of Capsule. The key to success was changing Apache's error level to debug. This gave me a starting point and from there a bit of trial and error and all was well.
I had two servers B777 and B767 which I used for local development. for development websites I used something like www.something.767 and www.something.777. All of the sites were listed in a hosts file.
For several years this worked just fine. For some reason I may never understand, last evening, I began to get the aforementioned error on both servers and on another I built this evening.
It seems that the problem was using numbers in the domain name. As soon as I changed a domain name from www.something.767 to www.something.local (or apparently any other non numeric characters) everything was back to normal.
Upvotes: 8