(Reverse) Proxy HTTP File Uploads
I am trying to reverse proxy HTTP file uploads through nginx. I think this is likely more secure as nginx has a proper HTTPS implementation with additional features (ChaCha20, OCSP …), which ejabberd does not offer. So I thought at least I could reverse proxy the HTTP file upload feature.
So I put up a usual reverse proxy configuration of nginx and set put_url in ejabberd to "https://example.com:443/ejabberdSubDir/fileupload". Ejabberd now uses the mod_http_upload request handler for some internal port (say 1234) where nginx proxies all requests too after removing the sub directory (/ejabberdSubDir) - done via a simple rewrite rewrite /ejabberdSubDir/(.*) /$1 break;. As I can see from ejabberd log everything works and the requests gets sent to ejabberd, but there ejabberd shows me an error:
2017-01-02 19:46:27.569 [info] <0.540.0>@ejabberd_listener:accept:333 (#Port<0.19990>) Accepted connection hidden_by_ejabberd:57532 -> ::FFFF:127.0.0.1:1234
2017-01-02 19:46:27.570 [info] <0.569.0>@ejabberd_http:init:163 started: {gen_tcp,#Port<0.19990>}
2017-01-02 19:46:27.575 [error] <0.569.0>@mod_http_upload:process:441 Cannot handle PUT request from hidden_by_ejabberd for %HOST%: {'EXIT',{noproc,{gen_server,call,['mod_http_upload_%HOST%/fileupload',{use_slot,[<<"de754bb7b1e8ad30593b859b2c22bb2d942cb2e4">>,<<"MmdQsD2AOMajnVfkMPxI8uCZn3BbVdrBsiEka1J8">>,<<"80f167e6-b721-4b2f-92d0-0f2f509e2f34.jpg">>],54598}]}}}
Tested with Conversations, without this reverse proxy everything works.