ログインが必要なサイト向けに安全なアップロードを提供する簡単なハックがあります。
基本的には、アップロード用に Authentication Based on Subrequest Result | NGINX Documentation の設定を行います。唯一の問題は、ログイン必須がオンになっている場合に 403/401 を返す URL を見つけられず、ログインせずにアップロードにアクセスすると 500 エラーが発生してしまうことです。これは、アップロード URL を持っている人がログインせずにアクセスした場合にのみ発生するため、それほど深刻ではないように思われます。
大まかには以下のようになります:
# JP
location = /auth {
internal;
proxy_pass http://discourse/categories;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
# END JP
location ~ ^/uploads/ {
auth_request /auth; #$JP
# NOTE: it is really annoying that we can't just define headers
# at the top level and inherit.
#