Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CUPS bad request

Tags:

linux

cups

I have a little problem with CUPS 2.2.7

This is my /etc/hosts file:

127.0.0.1   example.com

127.0.0.1   localhost

in http://localhost:631/ CUPS is working right

but in http://example.com:631/ it doesn't work on the same pc.

The message error in View error log is that one:

E [21/Feb/2019:11:54:18 +0100] [Client 33] Request from "localhost" using invalid Host: field "example.com:631".

The web page on Firefox print an error message Invalid request and give me an Error (error code: 400) but seems point on CUPS.

How to solve this problem so that example.com:631 points to localhost and CUPS answers it successfully instead of Error 400: Access Denied.

like image 774
Mattteo Leonelli Avatar asked Jul 09 '26 01:07

Mattteo Leonelli


2 Answers

By default cups responds only to HTTP requests with HTTP Host header equal to "localhost". To allow it servicing requests with different HTTP host headers use ServerAlias directive as described in the man cupsd.conf documentation. It's common to do the most unsafe thing and add

ServerAlias *

to /etc/cupsd.conf to allow all possible HTTP host headers to be serviced.

like image 137
KamilCuk Avatar answered Jul 12 '26 03:07

KamilCuk


I know this is old, but I too was experiencing the same issue recently and I resolved it by updating the following line in cupsd.conf from:

Listen 0.0.0.0:631

changed to:

Listen *:631

For those that maybe care to know, I'm running CUPS within a docker container, and this change corrects the "Bad Request" response.

like image 32
Dave Goodchild Avatar answered Jul 12 '26 04:07

Dave Goodchild



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!