Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into develop
This commit is contained in:
commit
5e37adedfb
|
@ -50,3 +50,12 @@ Logs can be watched by using `journalctl -fu pleroma.service`
|
||||||
|
|
||||||
### Standalone/run by other means
|
### Standalone/run by other means
|
||||||
Run `mix phx.server` in repository's root, it will output log into stdout/stderr
|
Run `mix phx.server` in repository's root, it will output log into stdout/stderr
|
||||||
|
|
||||||
|
### Using an upstream proxy for federation
|
||||||
|
|
||||||
|
Add the following to your `dev.secret.exs` or `prod.secret.exs` if you want to proxify all http requests that pleroma makes to an upstream proxy server:
|
||||||
|
|
||||||
|
config :pleroma, :http,
|
||||||
|
proxy_url: "127.0.0.1:8123"
|
||||||
|
|
||||||
|
This is useful for running pleroma inside Tor or i2p.
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
config :pleroma, :websub, Pleroma.Web.Websub
|
config :pleroma, :websub, Pleroma.Web.Websub
|
||||||
config :pleroma, :ostatus, Pleroma.Web.OStatus
|
config :pleroma, :ostatus, Pleroma.Web.OStatus
|
||||||
config :pleroma, :httpoison, HTTPoison
|
config :pleroma, :httpoison, Pleroma.HTTP
|
||||||
|
|
||||||
version = with {version, 0} <- System.cmd("git", ["rev-parse", "HEAD"]) do
|
version = with {version, 0} <- System.cmd("git", ["rev-parse", "HEAD"]) do
|
||||||
"Pleroma #{String.trim(version)}"
|
"Pleroma #{String.trim(version)}"
|
||||||
|
@ -40,6 +40,10 @@
|
||||||
_ -> "Pleroma dev"
|
_ -> "Pleroma dev"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Configures http settings, upstream proxy etc.
|
||||||
|
config :pleroma, :http,
|
||||||
|
proxy_url: nil
|
||||||
|
|
||||||
config :pleroma, :instance,
|
config :pleroma, :instance,
|
||||||
version: version,
|
version: version,
|
||||||
name: "Pleroma",
|
name: "Pleroma",
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
instance.example.com { # Your instance's domain
|
||||||
|
proxy / localhost:4000 {
|
||||||
|
websocket
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
defmodule Pleroma.HTTP do
|
||||||
|
use HTTPoison.Base
|
||||||
|
|
||||||
|
def process_request_options(options) do
|
||||||
|
config = Application.get_env(:pleroma, :http, [])
|
||||||
|
proxy = Keyword.get(config, :proxy_url, nil)
|
||||||
|
case proxy do
|
||||||
|
nil -> options
|
||||||
|
_ -> options ++ [proxy: proxy]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -2,6 +2,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do
|
||||||
use Pleroma.Web, :controller
|
use Pleroma.Web, :controller
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
@httpoison Application.get_env(:pleroma, :httpoison)
|
||||||
|
|
||||||
@max_body_length 25 * 1048576
|
@max_body_length 25 * 1048576
|
||||||
|
|
||||||
@cache_control %{
|
@cache_control %{
|
||||||
|
@ -29,7 +31,7 @@ def remote(conn, %{"sig" => sig, "url" => url}) do
|
||||||
|
|
||||||
defp proxy_request(link) do
|
defp proxy_request(link) do
|
||||||
headers = [{"user-agent", "Pleroma/MediaProxy; #{Pleroma.Web.base_url()} <#{Application.get_env(:pleroma, :instance)[:email]}>"}]
|
headers = [{"user-agent", "Pleroma/MediaProxy; #{Pleroma.Web.base_url()} <#{Application.get_env(:pleroma, :instance)[:email]}>"}]
|
||||||
options = [:insecure, {:follow_redirect, true}]
|
options = @httpoison.process_request_options([:insecure, {:follow_redirect, true}])
|
||||||
with \
|
with \
|
||||||
{:ok, 200, headers, client} <- :hackney.request(:get, link, headers, "", options),
|
{:ok, 200, headers, client} <- :hackney.request(:get, link, headers, "", options),
|
||||||
headers = Enum.into(headers, Map.new),
|
headers = Enum.into(headers, Map.new),
|
||||||
|
|
Loading…
Reference in New Issue