reverse_proxy: more headers
This commit is contained in:
parent
a2640c8088
commit
97b00d366f
|
@ -70,10 +70,12 @@ server {
|
||||||
client_max_body_size 16m;
|
client_max_body_size 16m;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /proxy {
|
location ~ ^/(media|proxy) {
|
||||||
proxy_cache pleroma_media_cache;
|
proxy_cache pleroma_media_cache;
|
||||||
proxy_cache_lock on;
|
proxy_cache_lock on;
|
||||||
proxy_ignore_client_abort on;
|
proxy_ignore_client_abort on;
|
||||||
|
proxy_buffering off;
|
||||||
|
chunked_transfer_encoding on;
|
||||||
proxy_pass http://localhost:4000;
|
proxy_pass http://localhost:4000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
defmodule Pleroma.ReverseProxy do
|
defmodule Pleroma.ReverseProxy do
|
||||||
@keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-none-match range)
|
@keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-unmodified-since if-none-match if-range range)
|
||||||
@resp_cache_headers ~w(etag date last-modified cache-control)
|
@resp_cache_headers ~w(etag date last-modified cache-control)
|
||||||
@keep_resp_headers @resp_cache_headers ++
|
@keep_resp_headers @resp_cache_headers ++
|
||||||
~w(content-type content-disposition accept-ranges vary)
|
~w(content-type content-disposition content-encoding content-range accept-ranges vary)
|
||||||
@default_cache_control_header "public, max-age=1209600"
|
@default_cache_control_header "public, max-age=1209600"
|
||||||
@valid_resp_codes [200, 206, 304]
|
@valid_resp_codes [200, 206, 304]
|
||||||
@max_read_duration :timer.minutes(2)
|
@max_read_duration :timer.minutes(2)
|
||||||
|
@ -226,8 +226,10 @@ defp downcase_headers(headers) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_content_type(headers) do
|
defp get_content_type(headers) do
|
||||||
{_, content_type} = List.keyfind(headers, "content-type", 0, {"content-type", "application/octet-stream"})
|
{_, content_type} =
|
||||||
[content_type | _] = String.split(content_type, ";")
|
List.keyfind(headers, "content-type", 0, {"content-type", "application/octet-stream"})
|
||||||
|
|
||||||
|
[content_type | _] = String.split(content_type, ";")
|
||||||
content_type
|
content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -259,12 +261,11 @@ defp build_req_headers(headers, opts) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp build_resp_headers(headers, opts) do
|
defp build_resp_headers(headers, opts) do
|
||||||
headers =
|
headers
|
||||||
headers
|
|> Enum.filter(fn {k, _} -> k in @keep_resp_headers end)
|
||||||
|> Enum.filter(fn {k, _} -> k in @keep_resp_headers end)
|
|> build_resp_cache_headers(opts)
|
||||||
|> build_resp_cache_headers(opts)
|
|> build_resp_content_disposition_header(opts)
|
||||||
|> build_resp_content_disposition_header(opts)
|
|> (fn headers -> headers ++ Keyword.get(opts, :resp_headers, []) end).()
|
||||||
|> (fn headers -> headers ++ Keyword.get(opts, :resp_headers, []) end).()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp build_resp_cache_headers(headers, opts) do
|
defp build_resp_cache_headers(headers, opts) do
|
||||||
|
@ -324,7 +325,6 @@ defp check_read_duration(duration, max)
|
||||||
if duration > max do
|
if duration > max do
|
||||||
{:error, :read_duration_exceeded}
|
{:error, :read_duration_exceeded}
|
||||||
else
|
else
|
||||||
Logger.debug("Duration #{inspect(duration)}")
|
|
||||||
{:ok, {duration, :erlang.system_time(:millisecond)}}
|
{:ok, {duration, :erlang.system_time(:millisecond)}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue