I would like to put a reverse proxy in front of CUPS to deal with "misbehaving" clients. For example clients which are slow senders (or receivers) and thereby blocking CUPS for all other clients. With NGINX you can for example use proxy_request_buffering on; and proxy_buffering on; to buffer the entire request (and response) body before sending it to CUPS (or back to the client). This should shield CUPS from clients which are slow senders and/or slow receivers. A reverse proxy can also help with things like request rate limiting. Some Linux clients sometimes start sending dozens of request per second ( https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/201 ). A reverse proxy can also do the TLS termination.
However I can't get a working reverse proxy setup with CUPS. I think this is mainly because CUPS does not support XFF headers such as X-Forwarded-For, X-Forwarded-Host, X-Forwarded-Proto, etc. From what I could gather this results in CUPS "seeing" the reverse proxy as the client and generating URL's like http://127.0.0.1:632/printers/pr0001 in the response. I can get as far as seeing all the printers shared by CUPS, but as soon as I try printing with them in applications like Gnome (for example the PDF viewer) or Chrome things fall apart.
I tried things in NGINX like sub_filter 'http://127.0.0.1:632' 'https://print.nl2.serviceplanet.nl:631'; to rewrite these URL's in the IPP responses, but ultimately none of this resulted in a working solution.
All information online about using a proxy server with CUPS is (as far as I can tell) just about the admin web interface. Not about doing actual IPP printing via the reverse proxy.
This is a snippet from NGINX config I tried (one of many), to give some idea of what I was trying to accomplish:
server {
listen 631 ssl;
server_name print.nl2.serviceplanet.nl;
# Contains 'ssl_protocols' config and such.
include tls-options.conf;
# SSL / TLS certificate config for the HTTPS listener.
ssl_certificate /usr/local/etc/nginx/ssl/print-nl2.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/print-nl2.key;
location / {
# Buffer the full request before sending it to CUPS. This shields CUPS
# from clients which are slow in sending their requests. A single slow
# sender or receiver can make CUPS slow for all clients.
proxy_request_buffering on;
# Also enable response buffering. If the client is slow to read the
# response this could also hinder CUPS.
proxy_buffering on;
# Buffer requests up to 15MB in memory. Rest goes to a temporary file.
client_body_buffer_size 15m;
client_max_body_size 128m;
proxy_pass http://127.0.0.1:632;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
I would like to put a reverse proxy in front of CUPS to deal with "misbehaving" clients. For example clients which are slow senders (or receivers) and thereby blocking CUPS for all other clients. With NGINX you can for example use
proxy_request_buffering on;andproxy_buffering on;to buffer the entire request (and response) body before sending it to CUPS (or back to the client). This should shield CUPS from clients which are slow senders and/or slow receivers. A reverse proxy can also help with things like request rate limiting. Some Linux clients sometimes start sending dozens of request per second ( https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/201 ). A reverse proxy can also do the TLS termination.However I can't get a working reverse proxy setup with CUPS. I think this is mainly because CUPS does not support XFF headers such as
X-Forwarded-For,X-Forwarded-Host,X-Forwarded-Proto, etc. From what I could gather this results in CUPS "seeing" the reverse proxy as the client and generating URL's likehttp://127.0.0.1:632/printers/pr0001in the response. I can get as far as seeing all the printers shared by CUPS, but as soon as I try printing with them in applications like Gnome (for example the PDF viewer) or Chrome things fall apart.I tried things in NGINX like
sub_filter 'http://127.0.0.1:632' 'https://print.nl2.serviceplanet.nl:631';to rewrite these URL's in the IPP responses, but ultimately none of this resulted in a working solution.All information online about using a proxy server with CUPS is (as far as I can tell) just about the admin web interface. Not about doing actual IPP printing via the reverse proxy.
This is a snippet from NGINX config I tried (one of many), to give some idea of what I was trying to accomplish: