We have a CentOS 7 server with Apache and NodeJS. We're using Apache to reverse proxy some routes to NodeJS.

We have a route (proxied to a NodeJS app) that allows a user to upload files which are then processed for file size, mimetype, and also scanned by ClamAV. If any one of those items fails (or there's an issue/crash with the backend NodeJS app), the file on the client's end just keeps uploading. This isn't an issue for small files or really fast connections but when someone is uploading, say, a 2GB file and the app fails or rejects the request within the first 10 MBs, that's a lot of wasted time for the end user.

I was wondering if there was a way to cancel or interrupt the client's request when the NodeJS backend sends a response to Apache or fails completely.

I'd like to send a response code 401 for unauthorized upload, 413 when the file is too big, and a 400 for either an invalid file type or a 'virus detected' scenario.

So far, none of my attempts at Apache configuration options seem to be making any difference.

Here's the relevant part of my current configuration:

<Location /uploader>
    <If "'%{REQUEST_METHOD}' == 'POST' || '%{REQUEST_METHOD}' == 'PATCH'">
        ProxyErrorOverride Off
        Order deny,allow
        Allow from all
        SetEnv proxy-sendchunks 1
        SetEnv proxy-sendchunked 1
        SecRuleEngine off
ProxyPass          /uploader http://localhost:5444
ProxyPassReverse   /uploader http://localhost:5444

Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.